UNPKG

@autobe/agent

Version:

AI backend server code generator

226 lines 12 kB
"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.orchestrateAnalyzeExtractDecisions = void 0; const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport")); const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize")); const typia_1 = __importDefault(require("typia")); const transformAnalyzeExtractDecisionsHistory_1 = require("./histories/transformAnalyzeExtractDecisionsHistory"); /** * Extract key decisions from a single file's section content. * * This orchestrator calls the LLM to read one file's full section content and * extract binary/discrete decisions as structured data. The extracted decisions * are then used for programmatic cross-file contradiction detection. * * Called in parallel for each file (excluding 00-toc.md) after per-file review * approves. */ const orchestrateAnalyzeExtractDecisions = (ctx, props) => __awaiter(void 0, void 0, void 0, function* () { var _a, _b; const pointer = { value: null, }; yield ctx.conversate(Object.assign({ source: SOURCE, controller: createController({ pointer }), enforceFunctionCall: true }, (0, transformAnalyzeExtractDecisionsHistory_1.transformAnalyzeExtractDecisionsHistory)(ctx, { file: props.file, sectionEvents: props.sectionEvents, }))); return { filename: props.file.filename, decisions: ((_b = (_a = pointer.value) === null || _a === void 0 ? void 0 : _a.decisions) !== null && _b !== void 0 ? _b : []).map((d) => ({ topic: d.topic, decision: d.decision, value: d.value, evidence: d.evidence, })), }; }); exports.orchestrateAnalyzeExtractDecisions = orchestrateAnalyzeExtractDecisions; function createController(props) { const application = __typia_transform__llmApplicationFinalize._llmApplicationFinalize({ functions: [ { name: "process", parameters: { description: "Current Type: {@link IAutoBeAnalyzeExtractDecisionsApplication.IProps}", type: "object", properties: { thinking: { description: "Reasoning: what decisions you extracted and why.", anyOf: [ { type: "null" }, { type: "string" } ] }, decisions: { description: "All binary/discrete decisions extracted from this file. Use normalized\nnames. Return an empty array if the file has no extractable decisions.", type: "array", items: { $ref: "#/$defs/IAutoBeAnalyzeExtractDecisionsApplication.IDecision" } } }, required: [ "decisions" ], additionalProperties: false, $defs: { "IAutoBeAnalyzeExtractDecisionsApplication.IDecision": { description: "A single extracted decision from the file's content.", type: "object", properties: { topic: { description: "Normalized topic grouping (lowercase, underscore-separated).", type: "string" }, decision: { description: "Specific decision within the topic (lowercase, underscore-separated).", type: "string" }, value: { description: "Binary: \"yes\"/\"no\". Discrete: short descriptive string.", type: "string" }, evidence: { description: "Short quote (1-2 sentences) from the source text supporting this\ndecision.", type: "string" } }, required: [ "topic", "decision", "value", "evidence" ] } } }, description: "Extract all binary/discrete decisions from a single file's sections.", validate: (() => { const _io0 = input => (null === input.thinking || undefined === input.thinking || "string" === typeof input.thinking) && (Array.isArray(input.decisions) && input.decisions.every(elem => "object" === typeof elem && null !== elem && _io1(elem))); const _io1 = input => "string" === typeof input.topic && "string" === typeof input.decision && "string" === typeof input.value && "string" === typeof input.evidence; const _vo0 = (input, _path, _exceptionable = true) => [null === input.thinking || undefined === input.thinking || "string" === typeof input.thinking || _report(_exceptionable, { path: _path + ".thinking", expected: "(null | string | undefined)", value: input.thinking }), (Array.isArray(input.decisions) || _report(_exceptionable, { path: _path + ".decisions", expected: "Array<IAutoBeAnalyzeExtractDecisionsApplication.IDecision>", value: input.decisions })) && input.decisions.map((elem, _index2) => ("object" === typeof elem && null !== elem || _report(_exceptionable, { path: _path + ".decisions[" + _index2 + "]", expected: "IAutoBeAnalyzeExtractDecisionsApplication.IDecision", value: elem })) && _vo1(elem, _path + ".decisions[" + _index2 + "]", true && _exceptionable) || _report(_exceptionable, { path: _path + ".decisions[" + _index2 + "]", expected: "IAutoBeAnalyzeExtractDecisionsApplication.IDecision", value: elem })).every(flag => flag) || _report(_exceptionable, { path: _path + ".decisions", expected: "Array<IAutoBeAnalyzeExtractDecisionsApplication.IDecision>", value: input.decisions })].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.topic || _report(_exceptionable, { path: _path + ".topic", expected: "string", value: input.topic }), "string" === typeof input.decision || _report(_exceptionable, { path: _path + ".decision", expected: "string", value: input.decision }), "string" === typeof input.value || _report(_exceptionable, { path: _path + ".value", expected: "string", value: input.value }), "string" === typeof input.evidence || _report(_exceptionable, { path: _path + ".evidence", expected: "string", value: input.evidence })].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: "IAutoBeAnalyzeExtractDecisionsApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeAnalyzeExtractDecisionsApplication.IProps", value: input }))(input, "$input", true); const success = 0 === errors.length; return success ? { success, data: input } : { success, errors, data: input }; } return { success: true, data: input }; }; })() } ] }); return { protocol: "class", name: SOURCE, application, execute: { process: (input) => { props.pointer.value = input; }, }, }; } const SOURCE = "analyzeSectionReview"; //# sourceMappingURL=orchestrateAnalyzeExtractDecisions.js.map