@autobe/agent
Version:
AI backend server code generator
347 lines • 17.2 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.orchestrateAnalyzeWrite = void 0;
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport.js"));
const core_1 = require("@agentica/core");
const typia_1 = __importDefault(require("typia"));
const assertSchemaModel_1 = require("../../context/assertSchemaModel");
const enforceToolCall_1 = require("../../utils/enforceToolCall");
const AutoBeAnalyzeFileSystem_1 = require("./AutoBeAnalyzeFileSystem");
const transformAnalyzeWriteHistories_1 = require("./transformAnalyzeWriteHistories");
const orchestrateAnalyzeWrite = (ctx, input) => {
const controller = createController({
model: ctx.model,
execute: new AutoBeAnalyzeFileSystem_1.AutoBeAnalyzeFileSystem({ [input.targetFile]: "" }),
setDocument: input.setDocument,
});
const agent = new core_1.MicroAgentica({
controllers: [controller],
model: ctx.model,
vendor: ctx.vendor,
config: Object.assign(Object.assign({}, ctx.config), { executor: {
describe: null,
} }),
histories: [...(0, transformAnalyzeWriteHistories_1.transformAnalyzeWriteHistories)(ctx, input)],
});
(0, enforceToolCall_1.enforceToolCall)(agent);
return agent;
};
exports.orchestrateAnalyzeWrite = orchestrateAnalyzeWrite;
function createController(props) {
(0, assertSchemaModel_1.assertSchemaModel)(props.model);
const application = collection[props.model];
return {
protocol: "class",
name: "Planning",
application,
execute: {
createOrUpdateFiles: (input) => __awaiter(this, void 0, void 0, function* () {
const fileMap = yield props.execute.createOrUpdateFiles(input);
props.setDocument(fileMap);
return fileMap;
}),
},
};
}
const claude = {
model: "claude",
options: {
reference: true,
separate: null
},
functions: [
{
name: "createOrUpdateFiles",
parameters: {
type: "object",
properties: {
files: {
type: "array",
items: {
$ref: "#/$defs/IFile"
},
minItems: 1
}
},
required: [
"files"
],
additionalProperties: false,
$defs: {
IFile: {
type: "object",
properties: {
reason: {
description: "Describe briefly why you made this document, and if you have any plans for\nthe next one.",
type: "string"
},
filename: {
description: "Filename to generate or overwrite.",
type: "string",
pattern: "((.*)\\.md)$"
},
markdown: {
description: "Markdown file content. Only write the content of the file. Do not include\nany questions. This should contain only the contents of the file. Do not\nwrite down any questions or appreciation. For example, remove a sentence\nsuch as \"Is it okay if we proceed with the table of contents? Please let me\nknow if there is anything to add or exclude from the table of contents!\"",
type: "string"
}
},
required: [
"reason",
"filename",
"markdown"
]
},
Recordstringstring: {
description: "Construct a type with a set of properties K of type T",
type: "object",
properties: {},
required: [],
additionalProperties: {
type: "string"
}
}
}
},
output: {
$ref: "#/$defs/Recordstringstring"
},
validate: (() => { const _io0 = input => Array.isArray(input.files) && (1 <= input.files.length && input.files.every(elem => "object" === typeof elem && null !== elem && _io1(elem))); const _io1 = input => "string" === typeof input.reason && ("string" === typeof input.filename && RegExp(/(.*)\.md$/).test(input.filename)) && "string" === typeof input.markdown; const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.files) || _report(_exceptionable, {
path: _path + ".files",
expected: "(Array<IFile> & MinItems<1>)",
value: input.files
})) && ((1 <= input.files.length || _report(_exceptionable, {
path: _path + ".files",
expected: "Array<> & MinItems<1>",
value: input.files
})) && input.files.map((elem, _index2) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".files[" + _index2 + "]",
expected: "IFile",
value: elem
})) && _vo1(elem, _path + ".files[" + _index2 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".files[" + _index2 + "]",
expected: "IFile",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".files",
expected: "(Array<IFile> & MinItems<1>)",
value: input.files
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.reason || _report(_exceptionable, {
path: _path + ".reason",
expected: "string",
value: input.reason
}), "string" === typeof input.filename && RegExp(/(.*)\.md$/).test(input.filename) || _report(_exceptionable, {
path: _path + ".filename",
expected: "`${string}.md`",
value: input.filename
}), "string" === typeof input.markdown || _report(_exceptionable, {
path: _path + ".markdown",
expected: "string",
value: input.markdown
})].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
if (false === __is(input)) {
errors = [];
_report = __typia_transform__validateReport._validateReport(errors);
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
path: _path + "",
expected: "__type",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "__type",
value: input
}))(input, "$input", true);
const success = 0 === errors.length;
return success ? {
success,
data: input
} : {
success,
errors,
data: input
};
}
return {
success: true,
data: input
};
}; })()
}
]
};
const collection = {
chatgpt: {
model: "chatgpt",
options: {
reference: true,
strict: false,
separate: null
},
functions: [
{
name: "createOrUpdateFiles",
parameters: {
type: "object",
properties: {
files: {
description: "@minItems 1",
type: "array",
items: {
$ref: "#/$defs/IFile"
}
}
},
required: [
"files"
],
additionalProperties: false,
$defs: {
IFile: {
type: "object",
properties: {
reason: {
description: "Describe briefly why you made this document, and if you have any plans for\nthe next one.",
type: "string"
},
filename: {
description: "Filename to generate or overwrite.\n\n\n@pattern ((.*)\\.md)$",
type: "string"
},
markdown: {
description: "Markdown file content. Only write the content of the file. Do not include\nany questions. This should contain only the contents of the file. Do not\nwrite down any questions or appreciation. For example, remove a sentence\nsuch as \"Is it okay if we proceed with the table of contents? Please let me\nknow if there is anything to add or exclude from the table of contents!\"",
type: "string"
}
},
required: [
"reason",
"filename",
"markdown"
]
},
Recordstringstring: {
description: "Construct a type with a set of properties K of type T",
type: "object",
properties: {},
required: [],
additionalProperties: {
type: "string"
}
}
}
},
output: {
$ref: "#/$defs/Recordstringstring"
},
validate: (() => { const _io0 = input => Array.isArray(input.files) && (1 <= input.files.length && input.files.every(elem => "object" === typeof elem && null !== elem && _io1(elem))); const _io1 = input => "string" === typeof input.reason && ("string" === typeof input.filename && RegExp(/(.*)\.md$/).test(input.filename)) && "string" === typeof input.markdown; const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.files) || _report(_exceptionable, {
path: _path + ".files",
expected: "(Array<IFile> & MinItems<1>)",
value: input.files
})) && ((1 <= input.files.length || _report(_exceptionable, {
path: _path + ".files",
expected: "Array<> & MinItems<1>",
value: input.files
})) && input.files.map((elem, _index2) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".files[" + _index2 + "]",
expected: "IFile",
value: elem
})) && _vo1(elem, _path + ".files[" + _index2 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".files[" + _index2 + "]",
expected: "IFile",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".files",
expected: "(Array<IFile> & MinItems<1>)",
value: input.files
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.reason || _report(_exceptionable, {
path: _path + ".reason",
expected: "string",
value: input.reason
}), "string" === typeof input.filename && RegExp(/(.*)\.md$/).test(input.filename) || _report(_exceptionable, {
path: _path + ".filename",
expected: "`${string}.md`",
value: input.filename
}), "string" === typeof input.markdown || _report(_exceptionable, {
path: _path + ".markdown",
expected: "string",
value: input.markdown
})].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
if (false === __is(input)) {
errors = [];
_report = __typia_transform__validateReport._validateReport(errors);
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
path: _path + "",
expected: "__type",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "__type",
value: input
}))(input, "$input", true);
const success = 0 === errors.length;
return success ? {
success,
data: input
} : {
success,
errors,
data: input
};
}
return {
success: true,
data: input
};
}; })()
}
]
},
claude,
llama: claude,
deepseek: claude,
"3.1": claude,
};
//# sourceMappingURL=orchestrateAnalyzeWrite.js.map