buckyos 0.7.170 → 0.7.177
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/cli/core/app.ts +2 -0
- package/cli/core/argv.ts +45 -239
- package/cli/core/command.ts +3 -35
- package/cli/dist/cli.mjs +2151 -673
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/modules/agent.ts +3 -1
- package/cli/modules/app.ts +13 -2
- package/cli/modules/pikg.ts +70 -1
- package/cli/modules/runtime.ts +497 -0
- package/cli/modules/skill.ts +583 -161
- package/cli/modules/skill_lint.ts +462 -0
- package/cli/version.ts +1 -1
- package/dist/account-7a7bde6f.mjs +105 -0
- package/dist/account-7a7bde6f.mjs.map +1 -0
- package/dist/account-b12ac6b9.js +2 -0
- package/dist/account-b12ac6b9.js.map +1 -0
- package/dist/aicc-67851c41.mjs +582 -0
- package/dist/aicc-67851c41.mjs.map +1 -0
- package/dist/aicc-ccb36ef7.js +2 -0
- package/dist/aicc-ccb36ef7.js.map +1 -0
- package/dist/aiworkspace_client.d.ts +36 -2
- package/dist/aiworkspace_client.d.ts.map +1 -1
- package/dist/app-frame.cjs +1 -1
- package/dist/app-frame.cjs.map +1 -1
- package/dist/app-frame.d.ts +56 -1
- package/dist/app-frame.d.ts.map +1 -1
- package/dist/app-frame.mjs +285 -4
- package/dist/app-frame.mjs.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +4 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.mjs +218 -194
- package/dist/browser.mjs.map +1 -1
- package/dist/content.cjs +1 -1
- package/dist/content.cjs.map +1 -1
- package/dist/content.d.ts +77 -0
- package/dist/content.d.ts.map +1 -1
- package/dist/content.mjs +65 -0
- package/dist/content.mjs.map +1 -1
- package/dist/content_objid-1aff74b6.js +2 -0
- package/dist/content_objid-1aff74b6.js.map +1 -0
- package/dist/content_objid-9232bcaf.mjs +29 -0
- package/dist/content_objid-9232bcaf.mjs.map +1 -0
- package/dist/content_objid.d.ts +15 -0
- package/dist/content_objid.d.ts.map +1 -0
- package/dist/did_object_client-6a1b108a.js +2 -0
- package/dist/did_object_client-6a1b108a.js.map +1 -0
- package/dist/did_object_client-7fa36f90.mjs +87 -0
- package/dist/did_object_client-7fa36f90.mjs.map +1 -0
- package/dist/did_object_client.d.ts +39 -0
- package/dist/did_object_client.d.ts.map +1 -0
- package/dist/executor_client-7ce0ddc7.js +13 -0
- package/dist/executor_client-7ce0ddc7.js.map +1 -0
- package/dist/{executor_client-5f4d0468.mjs → executor_client-bfc8a1e1.mjs} +308 -752
- package/dist/executor_client-bfc8a1e1.mjs.map +1 -0
- package/dist/executor_client.d.ts +129 -0
- package/dist/executor_client.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +218 -199
- package/dist/index.mjs.map +1 -1
- package/dist/internal/command_args.d.ts +67 -0
- package/dist/internal/command_args.d.ts.map +1 -0
- package/dist/krpc_client-26c2dc8b.js +2 -0
- package/dist/krpc_client-26c2dc8b.js.map +1 -0
- package/dist/krpc_client-673448e5.mjs +173 -0
- package/dist/krpc_client-673448e5.mjs.map +1 -0
- package/dist/krpc_client.d.ts +5 -1
- package/dist/krpc_client.d.ts.map +1 -1
- package/dist/{ndn_types-ab30fac0.mjs → ndn_types-0fac2499.mjs} +115 -215
- package/dist/ndn_types-0fac2499.mjs.map +1 -0
- package/dist/ndn_types-5b138882.js +2 -0
- package/dist/ndn_types-5b138882.js.map +1 -0
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.mjs +201 -194
- package/dist/node.mjs.map +1 -1
- package/dist/object_url-8fb5a7bf.js +2 -0
- package/dist/object_url-8fb5a7bf.js.map +1 -0
- package/dist/object_url-f72c1704.mjs +412 -0
- package/dist/object_url-f72c1704.mjs.map +1 -0
- package/dist/openai-ae2978de.mjs +163 -0
- package/dist/openai-ae2978de.mjs.map +1 -0
- package/dist/openai-f560d518.js +2 -0
- package/dist/openai-f560d518.js.map +1 -0
- package/dist/provision.cjs +6 -6
- package/dist/provision.cjs.map +1 -1
- package/dist/provision.mjs +4 -3
- package/dist/provision.mjs.map +1 -1
- package/dist/site_manager-11a7a468.mjs +6410 -0
- package/dist/site_manager-11a7a468.mjs.map +1 -0
- package/dist/site_manager-334b1a51.js +2 -0
- package/dist/site_manager-334b1a51.js.map +1 -0
- package/dist/{tus_client-b231b248.js → tus_client-809c90ab.js} +2 -2
- package/dist/{tus_client-b231b248.js.map → tus_client-809c90ab.js.map} +1 -1
- package/dist/{tus_client-d1ffe2d6.mjs → tus_client-893a3287.mjs} +2 -2
- package/dist/{tus_client-d1ffe2d6.mjs.map → tus_client-893a3287.mjs.map} +1 -1
- package/dist/xllm/core/action_parser.d.ts +15 -0
- package/dist/xllm/core/action_parser.d.ts.map +1 -0
- package/dist/xllm/core/behavior_loop.d.ts +20 -0
- package/dist/xllm/core/behavior_loop.d.ts.map +1 -0
- package/dist/xllm/core/behavior_result.d.ts +11 -0
- package/dist/xllm/core/behavior_result.d.ts.map +1 -0
- package/dist/xllm/core/config.d.ts +62 -0
- package/dist/xllm/core/config.d.ts.map +1 -0
- package/dist/xllm/core/context_window.d.ts +15 -0
- package/dist/xllm/core/context_window.d.ts.map +1 -0
- package/dist/xllm/core/deps.d.ts +97 -0
- package/dist/xllm/core/deps.d.ts.map +1 -0
- package/dist/xllm/core/errors.d.ts +94 -0
- package/dist/xllm/core/errors.d.ts.map +1 -0
- package/dist/xllm/core/interrupt.d.ts +31 -0
- package/dist/xllm/core/interrupt.d.ts.map +1 -0
- package/dist/xllm/core/json.d.ts +11 -0
- package/dist/xllm/core/json.d.ts.map +1 -0
- package/dist/xllm/core/json_check.d.ts +17 -0
- package/dist/xllm/core/json_check.d.ts.map +1 -0
- package/dist/xllm/core/loop.d.ts +135 -0
- package/dist/xllm/core/loop.d.ts.map +1 -0
- package/dist/xllm/core/messages.d.ts +18 -0
- package/dist/xllm/core/messages.d.ts.map +1 -0
- package/dist/xllm/core/observer.d.ts +14 -0
- package/dist/xllm/core/observer.d.ts.map +1 -0
- package/dist/xllm/core/open_runtime.d.ts +22 -0
- package/dist/xllm/core/open_runtime.d.ts.map +1 -0
- package/dist/xllm/core/prepare.d.ts +54 -0
- package/dist/xllm/core/prepare.d.ts.map +1 -0
- package/dist/xllm/core/prompt.d.ts +40 -0
- package/dist/xllm/core/prompt.d.ts.map +1 -0
- package/dist/xllm/core/protocol.d.ts +15 -0
- package/dist/xllm/core/protocol.d.ts.map +1 -0
- package/dist/xllm/core/result.d.ts +12 -0
- package/dist/xllm/core/result.d.ts.map +1 -0
- package/dist/xllm/core/run.d.ts +198 -0
- package/dist/xllm/core/run.d.ts.map +1 -0
- package/dist/xllm/core/rust_text.d.ts +20 -0
- package/dist/xllm/core/rust_text.d.ts.map +1 -0
- package/dist/xllm/core/site_policy.d.ts +5 -0
- package/dist/xllm/core/site_policy.d.ts.map +1 -0
- package/dist/xllm/core/store.d.ts +60 -0
- package/dist/xllm/core/store.d.ts.map +1 -0
- package/dist/xllm/core/suspension.d.ts +13 -0
- package/dist/xllm/core/suspension.d.ts.map +1 -0
- package/dist/xllm/core/tokenizer.d.ts +8 -0
- package/dist/xllm/core/tokenizer.d.ts.map +1 -0
- package/dist/xllm/core/types.d.ts +826 -0
- package/dist/xllm/core/types.d.ts.map +1 -0
- package/dist/xllm/core/xml.d.ts +19 -0
- package/dist/xllm/core/xml.d.ts.map +1 -0
- package/dist/xllm/dev/openai.d.ts +17 -0
- package/dist/xllm/dev/openai.d.ts.map +1 -0
- package/dist/xllm/dev/scripted.d.ts +46 -0
- package/dist/xllm/dev/scripted.d.ts.map +1 -0
- package/dist/xllm/dev.d.ts +5 -0
- package/dist/xllm/dev.d.ts.map +1 -0
- package/dist/xllm/hosts/browser/store.d.ts +41 -0
- package/dist/xllm/hosts/browser/store.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/deno_api.d.ts +103 -0
- package/dist/xllm/hosts/deno/deno_api.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/identity.d.ts +29 -0
- package/dist/xllm/hosts/deno/identity.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/index.d.ts +47 -0
- package/dist/xllm/hosts/deno/index.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/native_runtime.d.ts +93 -0
- package/dist/xllm/hosts/deno/native_runtime.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/native_tools.d.ts +105 -0
- package/dist/xllm/hosts/deno/native_tools.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/provider.d.ts +13 -0
- package/dist/xllm/hosts/deno/provider.d.ts.map +1 -0
- package/dist/xllm/hosts/deno/store.d.ts +60 -0
- package/dist/xllm/hosts/deno/store.d.ts.map +1 -0
- package/dist/xllm/index.d.ts +48 -0
- package/dist/xllm/index.d.ts.map +1 -0
- package/dist/xllm/providers/aicc.d.ts +22 -0
- package/dist/xllm/providers/aicc.d.ts.map +1 -0
- package/dist/xllm/providers/timeout.d.ts +12 -0
- package/dist/xllm/providers/timeout.d.ts.map +1 -0
- package/dist/xllm/runtime/compress.d.ts +149 -0
- package/dist/xllm/runtime/compress.d.ts.map +1 -0
- package/dist/xllm/runtime/did_object_resources.d.ts +21 -0
- package/dist/xllm/runtime/did_object_resources.d.ts.map +1 -0
- package/dist/xllm/runtime/hints.d.ts +23 -0
- package/dist/xllm/runtime/hints.d.ts.map +1 -0
- package/dist/xllm/runtime/site.d.ts +22 -0
- package/dist/xllm/runtime/site.d.ts.map +1 -0
- package/dist/xllm/runtime/site_manager.d.ts +38 -0
- package/dist/xllm/runtime/site_manager.d.ts.map +1 -0
- package/dist/xllm/runtime/site_tools.d.ts +76 -0
- package/dist/xllm/runtime/site_tools.d.ts.map +1 -0
- package/dist/xllm/runtime/step_renderer.d.ts +54 -0
- package/dist/xllm/runtime/step_renderer.d.ts.map +1 -0
- package/dist/xllm/runtime/task_model.d.ts +64 -0
- package/dist/xllm/runtime/task_model.d.ts.map +1 -0
- package/dist/xllm/runtime/tool_result.d.ts +39 -0
- package/dist/xllm/runtime/tool_result.d.ts.map +1 -0
- package/dist/xllm/runtime/types.d.ts +99 -0
- package/dist/xllm/runtime/types.d.ts.map +1 -0
- package/dist/xllm.cjs +2 -0
- package/dist/xllm.cjs.map +1 -0
- package/dist/xllm.mjs +1167 -0
- package/dist/xllm.mjs.map +1 -0
- package/dist/xllm_deno.cjs +2 -0
- package/dist/xllm_deno.cjs.map +1 -0
- package/dist/xllm_deno.mjs +2487 -0
- package/dist/xllm_deno.mjs.map +1 -0
- package/dist/xllm_dev.cjs +2 -0
- package/dist/xllm_dev.cjs.map +1 -0
- package/dist/xllm_dev.mjs +70 -0
- package/dist/xllm_dev.mjs.map +1 -0
- package/package.json +22 -1
- package/src/internal/command_args.ts +268 -0
- package/dist/executor_client-1ee523cf.js +0 -13
- package/dist/executor_client-1ee523cf.js.map +0 -1
- package/dist/executor_client-5f4d0468.mjs.map +0 -1
- package/dist/ndn_types-8c2696d5.js +0 -2
- package/dist/ndn_types-8c2696d5.js.map +0 -1
- package/dist/ndn_types-ab30fac0.mjs.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AiResponse, JsonValue, LLMBehaviorResult, ResolvedTool } from './types';
|
|
2
|
+
import type { LLMResultParser } from './deps';
|
|
3
|
+
/** Key of the report attachments inside `report_result` (`<artifacts>`). */
|
|
4
|
+
export declare const REPORT_ARTIFACTS_KEY = "artifacts";
|
|
5
|
+
export declare class XllmActionParser implements LLMResultParser {
|
|
6
|
+
private readonly actions;
|
|
7
|
+
constructor(actions: ResolvedTool[]);
|
|
8
|
+
private elementToCall;
|
|
9
|
+
parse(response: AiResponse): LLMBehaviorResult;
|
|
10
|
+
}
|
|
11
|
+
/** The attachments carried in a `report_result`. */
|
|
12
|
+
export declare function reportArtifacts(result: JsonValue | undefined): string[];
|
|
13
|
+
/** A `report_result` taken apart again: its attachments and the rest (`undefined` when nothing else was given). */
|
|
14
|
+
export declare function splitReportResult(result: JsonValue | undefined): [string[], JsonValue | undefined];
|
|
15
|
+
//# sourceMappingURL=action_parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action_parser.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/action_parser.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAc,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAS7C,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,cAAc,CAAA;AA8B/C,qBAAa,gBAAiB,YAAW,eAAe;IACtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;gBAE3C,OAAO,EAAE,YAAY,EAAE;IAInC,OAAO,CAAC,aAAa;IAwCrB,KAAK,CAAC,QAAQ,EAAE,UAAU,GAAG,iBAAiB;CAiE/C;AAaD,oDAAoD;AACpD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,EAAE,CAGvE;AAED,mHAAmH;AACnH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,GAAG,SAAS,CAAC,CAQlG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AiMessage, HistorySummaryRecord, LLMContextOutcome, LLMContextRequest, LLMContextSnapshot, LLMContextState, StepRecord } from './types';
|
|
2
|
+
import type { LLMContextDeps, StepRenderer } from './deps';
|
|
3
|
+
import { LLMContext } from './loop';
|
|
4
|
+
/** `StepRenderer::render_inherited` default. */
|
|
5
|
+
export declare function defaultRenderInherited(step: StepRecord): AiMessage;
|
|
6
|
+
/** `StepRenderer::render_summary` default. */
|
|
7
|
+
export declare function defaultRenderSummary(s: HistorySummaryRecord): AiMessage;
|
|
8
|
+
/**
|
|
9
|
+
* `StepRenderer::render_history`: the renderer's own when it has one, else
|
|
10
|
+
* the trait default — summaries, then each step (steps of another behavior
|
|
11
|
+
* as inherited records).
|
|
12
|
+
*/
|
|
13
|
+
export declare function renderStepHistory(r: StepRenderer, steps: StepRecord[], currentBehavior: string, summaries: HistorySummaryRecord[]): AiMessage[];
|
|
14
|
+
/** The behavior prompt without the inner transcript of the step in progress. */
|
|
15
|
+
export declare function materializeHistory(request: LLMContextRequest, state: LLMContextState, r: StepRenderer): AiMessage[];
|
|
16
|
+
/** The history a scheduler rewrites for a `context_limit_reached` snapshot (`LLMContext::rewritable_history`). */
|
|
17
|
+
export declare function rewritableHistory(snapshot: LLMContextSnapshot, deps: LLMContextDeps): AiMessage[];
|
|
18
|
+
/** The behavior outer loop (`LLMContext::run_behavior`). */
|
|
19
|
+
export declare function runBehavior(ctx: LLMContext): Promise<LLMContextOutcome>;
|
|
20
|
+
//# sourceMappingURL=behavior_loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behavior_loop.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/behavior_loop.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,SAAS,EAAuC,oBAAoB,EAAsC,iBAAiB,EAC3H,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAe,UAAU,EAChF,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAUnC,gDAAgD;AAChD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAGlE;AAED,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,SAAS,EAAE,CAY/I;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,EAAE,YAAY,GAAG,SAAS,EAAE,CAQnH;AAED,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,GAAG,SAAS,EAAE,CAGjG;AA6RD,4DAA4D;AAC5D,wBAAsB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuG7E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LLMBehaviorResult, StepDecision, StepRecord } from './types';
|
|
2
|
+
/** Checks a parsed step before it takes effect; the error is fed back to the model. */
|
|
3
|
+
export declare function validateBehaviorResult(r: LLMBehaviorResult): string | undefined;
|
|
4
|
+
/** `handover` / `yield` for a step without actions that does not end; `undefined` otherwise. */
|
|
5
|
+
export declare function behaviorDecision(r: LLMBehaviorResult): StepDecision | undefined;
|
|
6
|
+
export declare function stepFromResult(r: LLMBehaviorResult): StepRecord;
|
|
7
|
+
export declare function resultFromStep(step: StepRecord): LLMBehaviorResult;
|
|
8
|
+
export declare function syntheticErrorStep(message: string): StepRecord;
|
|
9
|
+
/** A step that only corrects a parse / policy failure. */
|
|
10
|
+
export declare function isCorrectionStep(step: StepRecord): boolean;
|
|
11
|
+
//# sourceMappingURL=behavior_result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behavior_result.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/behavior_result.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAG1E,uFAAuF;AACvF,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAY/E;AAED,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAI/E;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAa/D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CASlE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAO9D;AAED,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAG1D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { GroupDef, JsonValue, LlmContextFile, LoopModel, PromptConfig, ProviderConfig, ResultFormat, RunLogLevel, RunsDirSetting, RuntimeConfig, ShellSettings, ShellToolConfig, ToolSource, ToolsConfig } from './types';
|
|
2
|
+
export declare const DEFAULT_MAX_TOOL_ITERATIONS = 8;
|
|
3
|
+
export declare const DEFAULT_TIMEOUT_SECS = 3600;
|
|
4
|
+
export declare const DEFAULT_LLM_TIMEOUT_SECS = 600;
|
|
5
|
+
export declare const DEFAULT_CONTEXT_YIELD_RATIO = 0.8;
|
|
6
|
+
export declare const DEFAULT_MAX_CONSECUTIVE_ERRORS = 3;
|
|
7
|
+
export declare const DEFAULT_TASK_WAIT_MS = 25000;
|
|
8
|
+
export declare const MAX_IN_TOOL_WAIT_MS: number;
|
|
9
|
+
export declare const EXEC_DEFAULT_TIMEOUT_MS = 1800000;
|
|
10
|
+
export declare const EXEC_MAX_TIMEOUT_MS = 3600000;
|
|
11
|
+
export declare const BUILTIN_TOOL_GROUP_BASH = "bash";
|
|
12
|
+
export declare const BUILTIN_TOOL_GROUP_BASH_CORE = "bash_core";
|
|
13
|
+
/** Runtime kinds named by the design but not implemented by any executor. */
|
|
14
|
+
export declare const PLANNED_RUNTIME_KINDS: string[];
|
|
15
|
+
/** Runtime kinds the TS runtime knows (`site` is TS-only; Rust reports it as planned). */
|
|
16
|
+
export declare const KNOWN_RUNTIME_KINDS: string[];
|
|
17
|
+
/** Lexical path normalization (no filesystem access). */
|
|
18
|
+
export declare function normalizePath(p: string): string;
|
|
19
|
+
/** `resolve_config_path`: `~` stays for the host to expand, absolute paths as they are, the rest under `baseDir`. */
|
|
20
|
+
export declare function resolveConfigPath(raw: string, baseDir: string, home?: string): string;
|
|
21
|
+
/** Parse one `.llm_context` JSON object. `file` names it in diagnostics. */
|
|
22
|
+
export declare function parseLlmContextJson(file: string, value: JsonValue | undefined): LlmContextFile;
|
|
23
|
+
export declare function parseResultFormat(s: string): ResultFormat;
|
|
24
|
+
export declare function resultFormatString(f: ResultFormat): string;
|
|
25
|
+
export interface MergedConfig {
|
|
26
|
+
runtime: RuntimeConfig;
|
|
27
|
+
provider: ProviderConfig;
|
|
28
|
+
model?: string;
|
|
29
|
+
file_model?: string;
|
|
30
|
+
max_tokens?: number;
|
|
31
|
+
max_tool_iterations?: number;
|
|
32
|
+
llm_timeout?: number;
|
|
33
|
+
context_window?: number;
|
|
34
|
+
context_yield_ratio?: number;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
runs_dir?: RunsDirSetting;
|
|
37
|
+
loop_model?: LoopModel;
|
|
38
|
+
run_logs?: RunLogLevel;
|
|
39
|
+
result_format?: ResultFormat;
|
|
40
|
+
json?: boolean;
|
|
41
|
+
json_schema?: JsonValue;
|
|
42
|
+
tools: ToolsConfig;
|
|
43
|
+
prompt: PromptConfig;
|
|
44
|
+
sources: Record<string, string>;
|
|
45
|
+
files: string[];
|
|
46
|
+
}
|
|
47
|
+
export declare function mergeToolsConfig(base: ToolsConfig, over: ToolsConfig): ToolsConfig;
|
|
48
|
+
/** Merge parsed layers, ancestor first (`merge_config_layers`). */
|
|
49
|
+
export declare function mergeConfigLayers(layers: {
|
|
50
|
+
path: string;
|
|
51
|
+
file: LlmContextFile;
|
|
52
|
+
}[]): MergedConfig;
|
|
53
|
+
/** Tool configuration before expansion: defaults → top `tools` → selected group → `prompt.tools` → explicit switch. */
|
|
54
|
+
export declare function computeToolsConfig(merged: MergedConfig, group: GroupDef | undefined, cliTools: boolean | undefined, includeGroup: boolean): {
|
|
55
|
+
cfg: ToolsConfig;
|
|
56
|
+
sources: Record<string, string>;
|
|
57
|
+
};
|
|
58
|
+
export declare function shellSettings(cfg: ShellToolConfig | undefined, taskWaitMs: number): ShellSettings;
|
|
59
|
+
/** `RuntimeConfig::task_wait_ms`: the in-call wait budget for tasks. */
|
|
60
|
+
export declare function taskWaitMs(r: RuntimeConfig): number;
|
|
61
|
+
export declare function describeToolSource(s: ToolSource): string;
|
|
62
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACwB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAc,cAAc,EAC5G,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAc,aAAa,EAAE,eAAe,EAAE,UAAU,EAC9H,WAAW,EACZ,MAAM,SAAS,CAAA;AAKhB,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAC5C,eAAO,MAAM,oBAAoB,OAAO,CAAA;AACxC,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAC3C,eAAO,MAAM,2BAA2B,MAAM,CAAA;AAC9C,eAAO,MAAM,8BAA8B,IAAI,CAAA;AAC/C,eAAO,MAAM,oBAAoB,QAAS,CAAA;AAC1C,eAAO,MAAM,mBAAmB,QAAc,CAAA;AAC9C,eAAO,MAAM,uBAAuB,UAAY,CAAA;AAChD,eAAO,MAAM,mBAAmB,UAAY,CAAA;AAC5C,eAAO,MAAM,uBAAuB,SAAS,CAAA;AAC7C,eAAO,MAAM,4BAA4B,c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AE,YAAY,CAAA;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,CAYlF;AAeD,mEAAmE;AACnE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,EAAE,GAAG,YAAY,CAuChG;AAqDD,uHAAuH;AACvH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,GAAG,SAAS,EAAE,QAAQ,EAAE,OAAO,GAAG,SAAS,EACjH,YAAY,EAAE,OAAO,GAAG;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA6B9E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,CAMjG;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAEnD;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAMxD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AiMessage, ContextLimitKind, LLMContextRequest, LlmInferenceRequest, Tokenizer } from './types';
|
|
2
|
+
export declare const MESSAGE_OVERHEAD_TOKENS = 4;
|
|
3
|
+
export declare const MEDIA_PART_TOKENS = 1024;
|
|
4
|
+
export interface ContextLimits {
|
|
5
|
+
threshold?: number;
|
|
6
|
+
window?: number;
|
|
7
|
+
reserve: number;
|
|
8
|
+
}
|
|
9
|
+
/** The limits of `request`, or an error message for an invalid configuration. */
|
|
10
|
+
export declare function contextLimitsOf(request: LLMContextRequest): ContextLimits | string;
|
|
11
|
+
export declare function limitsActive(l: ContextLimits): boolean;
|
|
12
|
+
export declare function checkLimits(l: ContextLimits, estimated: number): ContextLimitKind | undefined;
|
|
13
|
+
export declare function estimateMessages(tok: Tokenizer, messages: AiMessage[]): number;
|
|
14
|
+
export declare function estimateRequest(tok: Tokenizer, req: LlmInferenceRequest): number;
|
|
15
|
+
//# sourceMappingURL=context_window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context_window.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/context_window.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGxH,eAAO,MAAM,uBAAuB,IAAI,CAAA;AACxC,eAAO,MAAM,iBAAiB,OAAO,CAAA;AAErC,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa,GAAG,MAAM,CAqBlF;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAEtD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAI7F;AAcD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,CAE9E;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAShF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { AiMessage, AiResponse, AiToolCall, CancelCause, DecisionVerdict, HistorySummaryRecord, Injection, LLMBehaviorResult, LLMContextRequest, LLMContextSnapshot, LlmClient, Observation, StepDecision, StepRecord, Tokenizer, ToolPolicy, ToolSpecLite, WorkEvent } from './types';
|
|
2
|
+
import type { JsonValue } from './types';
|
|
3
|
+
/** Per-call context handed to `ToolManager.callTool`: the run's interrupt / finish signals and deadline. */
|
|
4
|
+
export interface ToolCallCtx {
|
|
5
|
+
/** Aborts on interrupt or once the run deadline passed (not on a graceful finish). */
|
|
6
|
+
readonly signal: AbortSignal;
|
|
7
|
+
/** Epoch ms by which the run's wallclock budget ends, if any. */
|
|
8
|
+
readonly deadline_ms?: number;
|
|
9
|
+
/** The cause currently in force, if any (`deadline` only once it passed). */
|
|
10
|
+
cause(): CancelCause | undefined;
|
|
11
|
+
/** Resolves when the call should stop: interrupt, graceful finish or deadline. */
|
|
12
|
+
cancelled(): Promise<CancelCause>;
|
|
13
|
+
/** Resolves on interrupt or deadline only. */
|
|
14
|
+
cancelledHard(): Promise<CancelCause>;
|
|
15
|
+
}
|
|
16
|
+
/** A dispatch infrastructure failure (`Err(ToolDispatchError)`); `effect_unknown` whenever the call may have started. */
|
|
17
|
+
export declare class ToolDispatchException extends Error {
|
|
18
|
+
readonly effect_unknown: boolean;
|
|
19
|
+
constructor(message: string, effectUnknown: boolean);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Effect-side dispatcher. Resolves with a terminal observation (`error` is a
|
|
23
|
+
* business failure the model can react to); rejects with a
|
|
24
|
+
* `ToolDispatchException` for an infrastructure failure. On resume a call of
|
|
25
|
+
* an unfinished batch is dispatched again with the same `call_id`: the
|
|
26
|
+
* manager looks for the earlier work first and answers `unresolved` instead
|
|
27
|
+
* of running a non-idempotent tool again.
|
|
28
|
+
*/
|
|
29
|
+
export interface ToolManager {
|
|
30
|
+
callTool(call: AiToolCall, ctx: ToolCallCtx): Promise<Observation>;
|
|
31
|
+
listToolSpecs(): ToolSpecLite[];
|
|
32
|
+
}
|
|
33
|
+
/** Policy gate; a rejection (a thrown message) is fed back as a correctable error. */
|
|
34
|
+
export interface PolicyEngine {
|
|
35
|
+
gateToolCalls(request: LLMContextRequest, calls: AiToolCall[]): Promise<AiToolCall[]>;
|
|
36
|
+
gateActionCalls?(request: LLMContextRequest, calls: AiToolCall[]): Promise<AiToolCall[]>;
|
|
37
|
+
}
|
|
38
|
+
export interface WorklogSink {
|
|
39
|
+
emit(event: WorkEvent): void | Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The host's checkpoint hook, always called with the outer snapshot:
|
|
43
|
+
* `beforeToolCall` before every tool call / action, `beforeInference` at
|
|
44
|
+
* every inference boundary (resolve with an injection to add input; reject
|
|
45
|
+
* to stop the run with a checkpoint error).
|
|
46
|
+
*/
|
|
47
|
+
export interface CheckpointHook {
|
|
48
|
+
beforeToolCall?(snapshot: LLMContextSnapshot): Promise<void>;
|
|
49
|
+
beforeInference(snapshot: LLMContextSnapshot): Promise<Injection | undefined>;
|
|
50
|
+
validateReport?(snapshot: LLMContextSnapshot, result: LLMBehaviorResult, stepIndex: number): Promise<void>;
|
|
51
|
+
reviewDecision?(snapshot: LLMContextSnapshot, result: LLMBehaviorResult, stepIndex: number, decision: StepDecision): Promise<DecisionVerdict | undefined>;
|
|
52
|
+
}
|
|
53
|
+
/** Host check of a reply that met the reply contract's schema; reject with the message the model should fix. */
|
|
54
|
+
export interface OutputValidator {
|
|
55
|
+
validate(reply: JsonValue): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
/** Behavior loop: structured parser for model responses (rejects with the parse error). */
|
|
58
|
+
export interface LLMResultParser {
|
|
59
|
+
parse(response: AiResponse): LLMBehaviorResult;
|
|
60
|
+
}
|
|
61
|
+
/** Behavior loop: renders sedimented steps back into messages for the next inference. */
|
|
62
|
+
export interface StepRenderer {
|
|
63
|
+
render(step: StepRecord): [AiMessage, AiMessage];
|
|
64
|
+
renderInherited?(step: StepRecord): AiMessage;
|
|
65
|
+
renderSummary?(summary: HistorySummaryRecord): AiMessage;
|
|
66
|
+
/** The sedimented history; without it: summaries, then each step (another behavior's as inherited records). */
|
|
67
|
+
renderHistory?(steps: StepRecord[], currentBehavior: string, summaries: HistorySummaryRecord[]): AiMessage[];
|
|
68
|
+
}
|
|
69
|
+
export declare const MAX_INJECTIONS_PER_BOUNDARY = 4;
|
|
70
|
+
export interface LLMContextDeps {
|
|
71
|
+
llm: LlmClient;
|
|
72
|
+
tools: ToolManager;
|
|
73
|
+
policy?: PolicyEngine;
|
|
74
|
+
worklog?: WorklogSink;
|
|
75
|
+
tokenizer?: Tokenizer;
|
|
76
|
+
resultParser?: LLMResultParser;
|
|
77
|
+
stepRenderer?: StepRenderer;
|
|
78
|
+
checkpointHook?: CheckpointHook;
|
|
79
|
+
outputValidator?: OutputValidator;
|
|
80
|
+
}
|
|
81
|
+
export interface ResolvedDeps {
|
|
82
|
+
llm: LlmClient;
|
|
83
|
+
tools: ToolManager;
|
|
84
|
+
policy: PolicyEngine;
|
|
85
|
+
worklog: WorklogSink;
|
|
86
|
+
tokenizer: Tokenizer;
|
|
87
|
+
resultParser?: LLMResultParser;
|
|
88
|
+
stepRenderer?: StepRenderer;
|
|
89
|
+
checkpointHook?: CheckpointHook;
|
|
90
|
+
outputValidator?: OutputValidator;
|
|
91
|
+
}
|
|
92
|
+
export declare const allowAllPolicy: PolicyEngine;
|
|
93
|
+
export declare const noopWorklog: WorklogSink;
|
|
94
|
+
export declare function resolveDeps(d: LLMContextDeps): ResolvedDeps;
|
|
95
|
+
/** Specs the adapter may advertise, filtered by `ToolPolicy.mode` / `whitelist`. */
|
|
96
|
+
export declare function resolveToolSpecs(policy: ToolPolicy, tools: ToolManager): ToolSpecLite[];
|
|
97
|
+
//# sourceMappingURL=deps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/deps.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,SAAS,EAAE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AAE,GAAG,SAAS,EAAE,CAAA;CAC7G;AAED,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAE5C,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,SAAS,CAAA;IACd,KAAK,EAAE,WAAW,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,YAAY,CAAC,EAAE,eAAe,CAAA;IAC9B,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,SAAS,CAAA;IACd,KAAK,EAAE,WAAW,CAAA;IAClB,MAAM,EAAE,YAAY,CAAA;IACpB,OAAO,EAAE,WAAW,CAAA;IACpB,SAAS,EAAE,SAAS,CAAA;IACpB,YAAY,CAAC,EAAE,eAAe,CAAA;IAC9B,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC;AAED,eAAO,MAAM,cAAc,EAAE,YAI5B,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,WAA2B,CAAA;AAErD,wBAAgB,WAAW,CAAC,CAAC,EAAE,cAAc,GAAG,YAAY,CAO3D;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,YAAY,EAAE,CAKvF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ErrorSource, LLMComputeError, ProviderFailure, RunStatus } from './types';
|
|
2
|
+
/** A rejected `LlmClient.infer` (or any waist dependency) carries its `LLMComputeError`. */
|
|
3
|
+
export declare class LLMComputeException extends Error {
|
|
4
|
+
readonly error: LLMComputeError;
|
|
5
|
+
constructor(error: LLMComputeError);
|
|
6
|
+
}
|
|
7
|
+
export declare function providerError(failure: ProviderFailure, message: string): LLMComputeException;
|
|
8
|
+
/** What a dependency rejected with, as an `LLMComputeError`. A foreign error is a provider failure of unknown class. */
|
|
9
|
+
export declare function asComputeError(error: unknown): LLMComputeError;
|
|
10
|
+
/** Same text as Rust's `Display for LLMComputeError` (run.json `last_error.message`). */
|
|
11
|
+
export declare function computeErrorMessage(e: LLMComputeError): string;
|
|
12
|
+
export declare function errorSource(e: LLMComputeError): ErrorSource;
|
|
13
|
+
/** Feeding the error back to the model is a meaningful recovery; everything else ends the run. */
|
|
14
|
+
export declare function llmCorrectable(e: LLMComputeError): boolean;
|
|
15
|
+
export declare function infraRetrySafe(e: LLMComputeError): boolean;
|
|
16
|
+
export declare function refusedCode(failure: ProviderFailure): string | undefined;
|
|
17
|
+
/** Pre-run errors of the SDK (`XllmError` in Rust): once a run exists, results come back as a `RunOutcome`. */
|
|
18
|
+
export type XllmErrorDetail = {
|
|
19
|
+
kind: 'config';
|
|
20
|
+
file: string;
|
|
21
|
+
field: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'input';
|
|
25
|
+
message: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'capability';
|
|
28
|
+
message: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'runtime_mismatch';
|
|
31
|
+
message: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'recovery_blocked';
|
|
34
|
+
message: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'tools';
|
|
37
|
+
message: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'template';
|
|
40
|
+
origin: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'run_not_found';
|
|
44
|
+
run_id: string;
|
|
45
|
+
runs_dir: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'run_busy';
|
|
48
|
+
run_id: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'workdir_busy';
|
|
51
|
+
workdir: string;
|
|
52
|
+
run_id: string;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'run_terminal';
|
|
55
|
+
run_id: string;
|
|
56
|
+
status: RunStatus;
|
|
57
|
+
hint: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'not_resumable';
|
|
60
|
+
run_id: string;
|
|
61
|
+
reason: string;
|
|
62
|
+
} | {
|
|
63
|
+
kind: 'corrupted_run';
|
|
64
|
+
run_id: string;
|
|
65
|
+
reason: string;
|
|
66
|
+
} | {
|
|
67
|
+
kind: 'storage';
|
|
68
|
+
message: string;
|
|
69
|
+
} | {
|
|
70
|
+
kind: 'extract';
|
|
71
|
+
message: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'compressor';
|
|
74
|
+
message: string;
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'other';
|
|
77
|
+
message: string;
|
|
78
|
+
};
|
|
79
|
+
export type XllmErrorKind = XllmErrorDetail['kind'];
|
|
80
|
+
export declare class XllmError extends Error {
|
|
81
|
+
readonly detail: XllmErrorDetail;
|
|
82
|
+
constructor(detail: XllmErrorDetail);
|
|
83
|
+
get kind(): XllmErrorKind;
|
|
84
|
+
static config(file: string, field: string, reason: string): XllmError;
|
|
85
|
+
static input(message: string): XllmError;
|
|
86
|
+
static capability(message: string): XllmError;
|
|
87
|
+
static runtimeMismatch(message: string): XllmError;
|
|
88
|
+
static tools(message: string): XllmError;
|
|
89
|
+
static template(origin: string, reason: string): XllmError;
|
|
90
|
+
static notResumable(runId: string, reason: string): XllmError;
|
|
91
|
+
static storage(message: string): XllmError;
|
|
92
|
+
static other(message: string): XllmError;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WA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Aa,CAExB;IAED,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAIrE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAIxC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAI7C,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAIlD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAIxC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAI1D,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAI7D,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAI1C,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;CAGzC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class AbortState {
|
|
2
|
+
private abortedFlag;
|
|
3
|
+
private finishingFlag;
|
|
4
|
+
private reasonText;
|
|
5
|
+
private readonly controller;
|
|
6
|
+
private abortWaiters;
|
|
7
|
+
private stopWaiters;
|
|
8
|
+
/** Aborts on interrupt (not on a graceful finish). */
|
|
9
|
+
get signal(): AbortSignal;
|
|
10
|
+
set(reason: string): boolean;
|
|
11
|
+
setFinishing(reason: string): boolean;
|
|
12
|
+
isAborted(): boolean;
|
|
13
|
+
isFinishing(): boolean;
|
|
14
|
+
reason(): string | undefined;
|
|
15
|
+
/** Resolves once interrupted. */
|
|
16
|
+
aborted(): Promise<void>;
|
|
17
|
+
/** Resolves once interrupted or finishing. */
|
|
18
|
+
stopping(): Promise<void>;
|
|
19
|
+
private wake;
|
|
20
|
+
}
|
|
21
|
+
/** The scheduler's handle on a run (`LLMContextInterruptHandle`). */
|
|
22
|
+
export declare class LLMContextInterruptHandle {
|
|
23
|
+
private readonly state;
|
|
24
|
+
constructor(state: AbortState);
|
|
25
|
+
static standalone(): LLMContextInterruptHandle;
|
|
26
|
+
interrupt(reason: string): boolean;
|
|
27
|
+
finish(reason: string): boolean;
|
|
28
|
+
reason(): string | undefined;
|
|
29
|
+
}
|
|
30
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
31
|
+
//# sourceMappingURL=interrupt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interrupt.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/interrupt.ts"],"names":[],"mappings":"AAKA,qBAAa,UAAU;IACrB,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwB;IACnD,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,WAAW,CAAqB;IAExC,sDAAsD;IACtD,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAS5B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAQrC,SAAS,IAAI,OAAO;IAIpB,WAAW,IAAI,OAAO;IAItB,MAAM,IAAI,MAAM,GAAG,SAAS;IAI5B,iCAAiC;IACjC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,8CAA8C;IAC9C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzB,OAAO,CAAC,IAAI;CAUb;AAED,qEAAqE;AACrE,qBAAa,yBAAyB;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,UAAU;IAE9C,MAAM,CAAC,UAAU,IAAI,yBAAyB;IAI9C,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIlC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI/B,MAAM,IAAI,MAAM,GAAG,SAAS;CAG7B;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JsonValue } from './types';
|
|
2
|
+
/** `serde_json::to_string` of the value (after a JSON round trip, so `toJSON` and `undefined` behave as in JSON). */
|
|
3
|
+
export declare function canonicalJson(value: unknown): string;
|
|
4
|
+
/** Deep copy of a JSON value (drops `undefined` members like serialization does). */
|
|
5
|
+
export declare function cloneJson<T>(value: T): T;
|
|
6
|
+
/** Structural equality of two JSON values, `undefined` members ignored. */
|
|
7
|
+
export declare function jsonEqual(a: unknown, b: unknown): boolean;
|
|
8
|
+
export declare function isObject(v: unknown): v is {
|
|
9
|
+
[key: string]: JsonValue;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/json.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGxC,qHAAqH;AACrH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGpD;AAED,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAExC;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAEtE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JsonValue } from './types';
|
|
2
|
+
import type { OutputValidator } from './deps';
|
|
3
|
+
/** `undefined` when `value` matches `schema`, otherwise the first mismatch. */
|
|
4
|
+
export declare function validateJson(schema: JsonValue, value: JsonValue): string | undefined;
|
|
5
|
+
/** Parse a reply as one JSON value; one surrounding code fence is tolerated. */
|
|
6
|
+
export declare function parseReply(text: string): JsonValue;
|
|
7
|
+
/** A reply under a reply contract: parsed, matching the schema, accepted by the host's validator. */
|
|
8
|
+
export declare function checkReply(text: string, schema: JsonValue | undefined, validator?: OutputValidator): Promise<{
|
|
9
|
+
ok: true;
|
|
10
|
+
value: JsonValue;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
error: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** The correction message after a reply that broke the reply contract. */
|
|
16
|
+
export declare function repairMessage(error: string, schema: JsonValue | undefined): string;
|
|
17
|
+
//# sourceMappingURL=json_check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_check.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/json_check.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAiG7C,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAEpF;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAYlD;AAED,qGAAqG;AACrG,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,eAAe,GACvG,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBvE;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAKlF"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { AiMessage, AiResponse, AiToolCall, AiUsage, CancelCause, ContextLimitKind, ContextRunTrace, Injection, InjectionPosition, LLMComputeError, LLMContextOutcome, LLMContextRequest, LLMContextSnapshot, LLMContextState, LlmInferenceRequest, Observation, ResumeFill, Suspension, ToolExecRecord, ToolExecStatus } from './types';
|
|
2
|
+
import type { JsonValue } from './types';
|
|
3
|
+
import { ResolvedDeps, ToolCallCtx, ToolDispatchException } from './deps';
|
|
4
|
+
import type { LLMContextDeps } from './deps';
|
|
5
|
+
import { AbortState, LLMContextInterruptHandle } from './interrupt';
|
|
6
|
+
/** Current snapshot format; `resume` accepts only this version. */
|
|
7
|
+
export declare const SNAPSHOT_FORMAT_VERSION = 6;
|
|
8
|
+
export declare const DEFAULT_WRAP_UP_ROUNDS = 2;
|
|
9
|
+
export declare function stateFromRequest(req: LLMContextRequest, startedAtMs: number): LLMContextState;
|
|
10
|
+
export declare class LLMContext {
|
|
11
|
+
/** @internal */ request: LLMContextRequest;
|
|
12
|
+
/** @internal */ state: LLMContextState;
|
|
13
|
+
/** @internal */ readonly deps: ResolvedDeps;
|
|
14
|
+
/** @internal */ toolTrace: ToolExecRecord[];
|
|
15
|
+
/** @internal */ lastResponse: AiResponse;
|
|
16
|
+
/** @internal */ readonly abort: AbortState;
|
|
17
|
+
/** @internal Behavior step inner contexts: parser of native reports, outer hook and parent snapshot. */
|
|
18
|
+
nativeResultParser?: ResolvedDeps['resultParser'];
|
|
19
|
+
/** @internal */ toolCheckpointHook?: ResolvedDeps['checkpointHook'];
|
|
20
|
+
/** @internal */ innerParent?: {
|
|
21
|
+
parent: LLMContextSnapshot;
|
|
22
|
+
prefixLen: number;
|
|
23
|
+
};
|
|
24
|
+
constructor(request: LLMContextRequest, deps: LLMContextDeps, abort?: AbortState);
|
|
25
|
+
/**
|
|
26
|
+
* Resume from a snapshot. `fill` must match the snapshot's suspension;
|
|
27
|
+
* everything is validated before the context exists (rejects with an
|
|
28
|
+
* `LLMComputeException` carrying `snapshot_corrupted`).
|
|
29
|
+
*/
|
|
30
|
+
static resume(snapshot: LLMContextSnapshot, fill: ResumeFill, deps: LLMContextDeps): LLMContext;
|
|
31
|
+
interruptHandle(): LLMContextInterruptHandle;
|
|
32
|
+
snapshot(): LLMContextSnapshot;
|
|
33
|
+
suspension(): Suspension | undefined;
|
|
34
|
+
hostMeta(): JsonValue | undefined;
|
|
35
|
+
setHostMeta(host: JsonValue | undefined): void;
|
|
36
|
+
/** @internal */ isBehaviorMode(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Append user messages to the live context (between runs, or from the
|
|
39
|
+
* checkpoint hook at an inference boundary). Only valid at an inference
|
|
40
|
+
* boundary: suspended or mid-batch, nothing is placed.
|
|
41
|
+
*/
|
|
42
|
+
inject(injection: Injection): InjectionPosition;
|
|
43
|
+
/** @internal Run the checkpoint hook at an inference boundary; an outcome stops the run. */
|
|
44
|
+
runCheckpointHook(): Promise<LLMContextOutcome | undefined>;
|
|
45
|
+
/** Run the loop until an outcome is produced. */
|
|
46
|
+
run(): Promise<LLMContextOutcome>;
|
|
47
|
+
/** @internal The function call loop. */
|
|
48
|
+
runInner(): Promise<LLMContextOutcome>;
|
|
49
|
+
/** @internal One inference raced against the interrupt. */
|
|
50
|
+
infer(req: LlmInferenceRequest): Promise<{
|
|
51
|
+
kind: 'ok';
|
|
52
|
+
response: AiResponse;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'error';
|
|
55
|
+
error: LLMComputeError;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'aborted';
|
|
58
|
+
}>;
|
|
59
|
+
private acceptNativeReport;
|
|
60
|
+
/** @internal The outer snapshot handed to the hook before a tool call. */
|
|
61
|
+
toolCheckpointSnapshot(): LLMContextSnapshot;
|
|
62
|
+
/** @internal */
|
|
63
|
+
checkpointBeforeToolCall(): Promise<LLMContextOutcome | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Dispatch `state.tool_batch` serially, each call after a checkpoint.
|
|
66
|
+
* Business errors do not stop the batch; infrastructure failures do and
|
|
67
|
+
* the calls that never ran are answered as `unresolved`.
|
|
68
|
+
*/
|
|
69
|
+
private runToolBatch;
|
|
70
|
+
/** @internal End the batch in progress, returning its undispatched calls. */
|
|
71
|
+
takeBatchRest(): AiToolCall[];
|
|
72
|
+
/** @internal Context of one tool call; `release` clears its timers. */
|
|
73
|
+
toolCallCtx(): {
|
|
74
|
+
ctx: ToolCallCtx;
|
|
75
|
+
release: () => void;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Dispatch one call. A graceful finish requested while the tool runs
|
|
79
|
+
* becomes an interrupt once `finish_grace_ms` passed without the tool
|
|
80
|
+
* returning.
|
|
81
|
+
*/
|
|
82
|
+
dispatchTool(call: AiToolCall, ctx: ToolCallCtx): Promise<{
|
|
83
|
+
ok: Observation;
|
|
84
|
+
} | {
|
|
85
|
+
err: ToolDispatchException;
|
|
86
|
+
}>;
|
|
87
|
+
/** @internal After a legitimate inline `cancelled`: end the run according to `cause`. */
|
|
88
|
+
stopAfterCancel(cause: CancelCause): LLMContextOutcome;
|
|
89
|
+
/** @internal */
|
|
90
|
+
finishInterruptedAfterTool(): LLMContextOutcome;
|
|
91
|
+
/** @internal */
|
|
92
|
+
finishSettled(): LLMContextOutcome;
|
|
93
|
+
/** @internal Answer `remaining` with `cancelled { effect_unknown: false }` (never started). */
|
|
94
|
+
cancelToolBatch(remaining: AiToolCall[], reason: string): void;
|
|
95
|
+
/** @internal Suspend with `context_limit_reached` at an inference boundary. */
|
|
96
|
+
suspendContextLimit(which: ContextLimitKind, estimated: number | undefined, history: AiMessage[]): LLMContextOutcome;
|
|
97
|
+
/** @internal An `error` for a run that must not start; leaves the state untouched. */
|
|
98
|
+
refuse(message: string): LLMContextOutcome;
|
|
99
|
+
/** @internal */
|
|
100
|
+
recordTool(call: AiToolCall, status: ToolExecStatus, durationMs: number, error?: string): void;
|
|
101
|
+
/** @internal Answer `remaining` with `unresolved { effect_unknown: false }`. */
|
|
102
|
+
abortToolBatch(remaining: AiToolCall[], reason: string): void;
|
|
103
|
+
private abortStartedCall;
|
|
104
|
+
/** @internal Push the assistant message and answer each call with an error carrying `reason`. */
|
|
105
|
+
rejectToolBatch(message: AiMessage, calls: AiToolCall[], reason: string): void;
|
|
106
|
+
/** @internal */
|
|
107
|
+
buildInferenceRequest(): LlmInferenceRequest;
|
|
108
|
+
/** @internal Wrap-up mode: tool iterations used up, wrap-up batches left. */
|
|
109
|
+
inWrapUp(): boolean;
|
|
110
|
+
/** @internal A batch of only wrap-up tools may run without a tool iteration. */
|
|
111
|
+
admitsWrapUp(names: string[]): boolean;
|
|
112
|
+
/** @internal */
|
|
113
|
+
accountResponse(response: AiResponse): void;
|
|
114
|
+
/** @internal */
|
|
115
|
+
checkWallclockBudget(): LLMContextOutcome | undefined;
|
|
116
|
+
/** @internal */
|
|
117
|
+
checkTokenBudget(): LLMContextOutcome | undefined;
|
|
118
|
+
/** @internal `interrupted` from the pre-inference snapshot: resuming retries that inference. */
|
|
119
|
+
finishInterrupted(snapshot: LLMContextSnapshot, requestedAtMs: number): LLMContextOutcome;
|
|
120
|
+
/** @internal */
|
|
121
|
+
takeTrace(): ContextRunTrace;
|
|
122
|
+
/** @internal Terminal `error` carrying the audit trace of this run. */
|
|
123
|
+
finishError(error: LLMComputeError): LLMContextOutcome;
|
|
124
|
+
/** `undefined` when the reply must be corrected and another inference run. */
|
|
125
|
+
private finishDone;
|
|
126
|
+
/** @internal */
|
|
127
|
+
handleError(error: LLMComputeError): LLMContextOutcome | undefined;
|
|
128
|
+
/** @internal Count one failed iteration; an outcome when the cap is exceeded. */
|
|
129
|
+
bumpConsecutiveErrors(error: LLMComputeError): LLMContextOutcome | undefined;
|
|
130
|
+
/** @internal */
|
|
131
|
+
emit(event: Parameters<ResolvedDeps['worklog']['emit']>[0]): Promise<void>;
|
|
132
|
+
/** @internal Usage of this context so far. */
|
|
133
|
+
usage(): AiUsage;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/loop.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAiB,eAAe,EAAE,SAAS,EACpH,iBAAiB,EAAqB,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAChI,mBAAmB,EAAE,WAAW,EAAE,UAAU,EAAc,UAAU,EAAE,cAAc,EAAE,cAAc,EACrG,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EACwB,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAC9E,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAUnE,mEAAmE;AACnE,eAAO,MAAM,uBAAuB,IAAI,CAAA;AACxC,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAKvC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,eAAe,CAa7F;AAQD,qBAAa,UAAU;IACrB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,CAAA;IAC3C,gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAA;IACvC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC5C,gBAAgB,C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S,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM;IAOtD,OAAO,CAAC,gBAAgB;IAMxB,iGAAiG;IACjG,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM;IAQvE,gBAAgB;IAChB,qBAAqB,IAAI,mBAAmB;IA+B5C,6EAA6E;IAC7E,QAAQ,IAAI,OAAO;IAMnB,gFAAgF;IAChF,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO;IAKtC,gBAAgB;IAChB,eAAe,CAAC,QAAQ,EAAE,UAAU;IAIpC,gBAAgB;IAChB,oBAAoB,IAAI,iBAAiB,GAAG,SAAS;IASrD,gBAAgB;IAChB,gBAAgB,IAAI,iBAAiB,GAAG,SAAS;IASjD,gGAAgG;IAChG,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,GAAG,iBAAiB;IAQzF,gBAAgB;IAChB,SAAS,IAAI,eAAe;IAO5B,uEAAuE;IACvE,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB;IAItD,8EAA8E;YAChE,UAAU;IA8CxB,gBAAgB;IAChB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB,GAAG,SAAS;IAKlE,iFAAiF;IACjF,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB,GAAG,SAAS;IAO5E,gBAAgB;IACV,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAIhE,8CAA8C;IAC9C,KAAK,IAAI,OAAO;CAGjB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AiMessage, AiRole } from '../../aicc_client';
|
|
2
|
+
import type { AiResponse, AiToolCall, AiUsage, JsonValue, Observation } from './types';
|
|
3
|
+
export declare function nowMs(): number;
|
|
4
|
+
export declare function textMessage(role: AiRole, text: string): AiMessage;
|
|
5
|
+
/** All text blocks joined by `\n` (`AiMessage::text_content`). */
|
|
6
|
+
export declare function textContent(message: AiMessage): string;
|
|
7
|
+
/** Tool-use blocks as calls, in message order (`AiMessage::tool_calls`). */
|
|
8
|
+
export declare function toolCalls(message: AiMessage): AiToolCall[];
|
|
9
|
+
/** `AiResponse::validate`: an assistant message with blocks allowed for the role and tool calls with ids. */
|
|
10
|
+
export declare function validateResponse(response: AiResponse): string | undefined;
|
|
11
|
+
/** The tool-role message carrying one observation back to the model. */
|
|
12
|
+
export declare function toolObservationMessage(callId: string, observation: Observation): AiMessage;
|
|
13
|
+
/** Sum of two usages (`merge_usage`): counters add, `cost` adds per currency, `reported_cost` is dropped. */
|
|
14
|
+
export declare function mergeUsage(left: AiUsage, right: AiUsage): AiUsage;
|
|
15
|
+
/** `add_usage` of the run record: input / output / total tokens and request units. */
|
|
16
|
+
export declare function addRecordUsage(base: AiUsage | undefined, extra: AiUsage): AiUsage;
|
|
17
|
+
export declare function argsOf(args: Record<string, JsonValue> | undefined): Record<string, JsonValue>;
|
|
18
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,SAAS,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAItF,wBAAgB,KAAK,IAAI,MAAM,CAE9B;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAEjE;AAED,kEAAkE;AAClE,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAEtD;AAED,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,UAAU,EAAE,CAM1D;AAED,6GAA6G;AAC7G,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAUzE;AAED,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,SAAS,CA8B1F;AAQD,6GAA6G;AAC7G,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAUjE;AAOD,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAMjF;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAE7F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RunObserver, WorkEvent } from './types';
|
|
2
|
+
import type { WorklogSink } from './deps';
|
|
3
|
+
export declare const noopObserver: RunObserver;
|
|
4
|
+
export declare class ObserverWorklog implements WorklogSink {
|
|
5
|
+
private readonly runId;
|
|
6
|
+
private readonly observer;
|
|
7
|
+
private llmStartedAt;
|
|
8
|
+
private readonly commands;
|
|
9
|
+
constructor(runId: string, observer: RunObserver);
|
|
10
|
+
emit(event: WorkEvent): void;
|
|
11
|
+
private map;
|
|
12
|
+
private takeCommand;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=observer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../../../src/xllm/core/observer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAGzC,eAAO,MAAM,YAAY,EAAE,WAA8B,CAAA;AAIzD,qBAAa,eAAgB,YAAW,WAAW;IAIrC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAU,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrE,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;gBAExB,KAAK,EAAE,MAAM,EAAmB,QAAQ,EAAE,WAAW;IAElF,IAAI,CAAC,KAAK,EAAE,SAAS;IAKrB,OAAO,CAAC,GAAG;IA0CX,OAAO,CAAC,WAAW;CAKpB"}
|