@polpo-ai/core 0.2.5 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/assessment-orchestrator.d.ts +124 -0
- package/dist/assessment-orchestrator.d.ts.map +1 -0
- package/dist/assessment-orchestrator.js +790 -0
- package/dist/assessment-orchestrator.js.map +1 -0
- package/dist/assessment-prompts.d.ts +45 -0
- package/dist/assessment-prompts.d.ts.map +1 -0
- package/dist/assessment-prompts.js +205 -0
- package/dist/assessment-prompts.js.map +1 -0
- package/dist/assessment-schemas.d.ts +102 -0
- package/dist/assessment-schemas.d.ts.map +1 -0
- package/dist/assessment-schemas.js +112 -0
- package/dist/assessment-schemas.js.map +1 -0
- package/dist/assessment-scoring.d.ts +26 -0
- package/dist/assessment-scoring.d.ts.map +1 -0
- package/dist/assessment-scoring.js +129 -0
- package/dist/assessment-scoring.js.map +1 -0
- package/dist/assessor.d.ts +36 -0
- package/dist/assessor.d.ts.map +1 -0
- package/dist/assessor.js +209 -0
- package/dist/assessor.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/mission-executor.d.ts +253 -0
- package/dist/mission-executor.d.ts.map +1 -0
- package/dist/mission-executor.js +1053 -0
- package/dist/mission-executor.js.map +1 -0
- package/dist/orchestrator-context.d.ts +11 -5
- package/dist/orchestrator-context.d.ts.map +1 -1
- package/dist/orchestrator-engine.d.ts +500 -0
- package/dist/orchestrator-engine.d.ts.map +1 -0
- package/dist/orchestrator-engine.js +454 -0
- package/dist/orchestrator-engine.js.map +1 -0
- package/dist/question-detector.d.ts +31 -0
- package/dist/question-detector.d.ts.map +1 -0
- package/dist/question-detector.js +65 -0
- package/dist/question-detector.js.map +1 -0
- package/dist/retry.d.ts +22 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +47 -0
- package/dist/retry.js.map +1 -0
- package/dist/spawner.d.ts +43 -0
- package/dist/spawner.d.ts.map +1 -0
- package/dist/spawner.js +2 -0
- package/dist/spawner.js.map +1 -0
- package/dist/task-runner.d.ts +43 -0
- package/dist/task-runner.d.ts.map +1 -0
- package/dist/task-runner.js +487 -0
- package/dist/task-runner.js.map +1 -0
- package/package.json +50 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenPolpo Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AssessmentOrchestrator — handles the full assessment pipeline:
|
|
3
|
+
* result collection → question detection → assessment → auto-correction → judge → fix/retry/fail.
|
|
4
|
+
*
|
|
5
|
+
* Pure core version — ZERO Node.js imports.
|
|
6
|
+
* All runtime-specific behavior is injected via OrchestratorContext ports
|
|
7
|
+
* and the optional AssessmentPorts interface.
|
|
8
|
+
*/
|
|
9
|
+
import type { OrchestratorContext } from "./orchestrator-context.js";
|
|
10
|
+
import type { Task, TaskResult, ModelConfig } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Optional ports for runtime-specific operations that cannot go through
|
|
13
|
+
* OrchestratorContext (to avoid modifying the shared interface).
|
|
14
|
+
*
|
|
15
|
+
* Shell layer creates these from Node.js APIs (node:fs, node:path);
|
|
16
|
+
* cloud/test environments can provide stubs or omit them.
|
|
17
|
+
*/
|
|
18
|
+
export interface AssessmentPorts {
|
|
19
|
+
/** Check if a file path exists (sync). Maps to node:fs existsSync. */
|
|
20
|
+
fileExists?: (path: string) => boolean;
|
|
21
|
+
/** Read directory entries with type info (sync). Maps to node:fs readdirSync. */
|
|
22
|
+
readDir?: (dir: string) => Array<{
|
|
23
|
+
name: string;
|
|
24
|
+
isFile: boolean;
|
|
25
|
+
isDirectory: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
/** Join path segments. Maps to node:path join. */
|
|
28
|
+
joinPath?: (...parts: string[]) => string;
|
|
29
|
+
/** Extract file name from path. Maps to node:path basename. */
|
|
30
|
+
baseName?: (path: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate an answer to an agent's question.
|
|
33
|
+
* Shell layer implements this using shared memory + sibling tasks + LLM.
|
|
34
|
+
* When not provided, question auto-answering is skipped (falls through to assessment).
|
|
35
|
+
*/
|
|
36
|
+
generateAnswer?: (task: Task, question: string, model?: string | ModelConfig) => Promise<string>;
|
|
37
|
+
/** LLM-based question classifier. Overrides core classifyAsQuestion when provided. */
|
|
38
|
+
classifyAsQuestion?: (stdout: string, model?: string | ModelConfig) => Promise<{
|
|
39
|
+
isQuestion: boolean;
|
|
40
|
+
question: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Handles the full assessment pipeline: result collection → question detection →
|
|
45
|
+
* assessment → auto-correction → judge → fix/retry/fail.
|
|
46
|
+
*/
|
|
47
|
+
export declare class AssessmentOrchestrator {
|
|
48
|
+
private ctx;
|
|
49
|
+
private ports;
|
|
50
|
+
constructor(ctx: OrchestratorContext, ports?: AssessmentPorts);
|
|
51
|
+
/**
|
|
52
|
+
* Build a rich ReviewContext from all available data sources:
|
|
53
|
+
* - RunStore activity (files, tool counts)
|
|
54
|
+
* - TaskResult (stdout, stderr, exit code, duration)
|
|
55
|
+
* - JSONL transcript log (execution timeline)
|
|
56
|
+
* - Task outcomes
|
|
57
|
+
*/
|
|
58
|
+
private buildReviewContext;
|
|
59
|
+
/**
|
|
60
|
+
* Attempt to transition a task to "done", but first run the before:task:complete
|
|
61
|
+
* hook so approval gates (and any other hooks) can block it.
|
|
62
|
+
* Returns true if the task transitioned to done, false if a hook blocked it.
|
|
63
|
+
*/
|
|
64
|
+
private transitionToDone;
|
|
65
|
+
/** Resolve effective confidence: explicit field, or default by type. */
|
|
66
|
+
private getConfidence;
|
|
67
|
+
/** Check if any failed checks correspond to estimated expectations. */
|
|
68
|
+
private hasEstimatedFailures;
|
|
69
|
+
handleResult(taskId: string, result: TaskResult): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* LLM-classify a potential question, then either resolve+rerun or proceed to assessment.
|
|
72
|
+
*/
|
|
73
|
+
private handlePossibleQuestion;
|
|
74
|
+
/**
|
|
75
|
+
* Auto-answer an agent's question and re-run the task (no retry burn).
|
|
76
|
+
*/
|
|
77
|
+
private resolveAndRerun;
|
|
78
|
+
/**
|
|
79
|
+
* Inline answer generation using ctx.memoryStore + ctx.registry + ctx.queryLLM.
|
|
80
|
+
* Equivalent to the shell's generateAnswer() but without Node.js dependencies.
|
|
81
|
+
*/
|
|
82
|
+
private generateAnswerInline;
|
|
83
|
+
/**
|
|
84
|
+
* Run assessment with retry when all LLM reviewers fail.
|
|
85
|
+
* Retries up to maxAssessmentRetries times before returning the failed result.
|
|
86
|
+
*/
|
|
87
|
+
private runAssessmentWithRetry;
|
|
88
|
+
/**
|
|
89
|
+
* Standard assessment flow: run expectations/metrics, then mark done/failed/fix/retry.
|
|
90
|
+
*/
|
|
91
|
+
private proceedToAssessment;
|
|
92
|
+
/**
|
|
93
|
+
* Core assessment flow — extracted to allow hook interception in proceedToAssessment.
|
|
94
|
+
*/
|
|
95
|
+
private runAssessmentFlow;
|
|
96
|
+
/**
|
|
97
|
+
* Auto-correct expectations when assessment fails due to wrong paths.
|
|
98
|
+
* If the only failures are file_exists checks with incorrect paths, search
|
|
99
|
+
* for the actual files using agent activity + filesystem, update expectations,
|
|
100
|
+
* and re-assess. Returns true if auto-correction succeeded (task is done).
|
|
101
|
+
*/
|
|
102
|
+
private tryAutoCorrectExpectations;
|
|
103
|
+
/** Search for a file by name in common project locations.
|
|
104
|
+
* Searches agentWorkDir first (where the agent actually created files),
|
|
105
|
+
* then falls back to workDir (the project root) when they differ. */
|
|
106
|
+
private findFileByName;
|
|
107
|
+
/**
|
|
108
|
+
* LLM judge: analyze failed estimated expectations vs agent output and decide
|
|
109
|
+
* whether they are wrong (correct them) or the agent's work is wrong (fix phase).
|
|
110
|
+
* Only operates on estimated expectations — firm ones are never touched.
|
|
111
|
+
* Returns true if expectations were corrected and re-assessment passed.
|
|
112
|
+
*/
|
|
113
|
+
private judgeExpectations;
|
|
114
|
+
/** Recursive directory search (bounded depth). Uses injected file system ports. */
|
|
115
|
+
private searchDir;
|
|
116
|
+
/**
|
|
117
|
+
* Fix phase: when execution succeeded but review failed, try a targeted fix
|
|
118
|
+
* without burning a full retry. After maxFixAttempts, fall back to full retry.
|
|
119
|
+
*/
|
|
120
|
+
private fixOrRetry;
|
|
121
|
+
/** @internal — exposed for test access via Orchestrator facade */
|
|
122
|
+
retryOrFail(taskId: string, _task: Task, result: TaskResult): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=assessment-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment-orchestrator.d.ts","sourceRoot":"","sources":["../src/assessment-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAoD,WAAW,EAAE,MAAM,YAAY,CAAC;AAUlH;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,iFAAiF;IACjF,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC1F,kDAAkD;IAClD,QAAQ,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IAC1C,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACjG,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,KAAK,OAAO,CAAC;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3H;AAED;;;GAGG;AACH,qBAAa,sBAAsB;IAGrB,O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