@caplets/core 0.23.0 → 0.24.0
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/dist/cli/code-mode.d.ts +3 -0
- package/dist/code-mode/api.d.ts +3 -1
- package/dist/code-mode/diagnostics.d.ts +8 -0
- package/dist/code-mode/index.d.ts +1 -1
- package/dist/code-mode/journal.d.ts +103 -0
- package/dist/code-mode/runner.d.ts +5 -0
- package/dist/code-mode/runtime-api.generated.d.ts +1 -1
- package/dist/code-mode/sandbox.d.ts +14 -1
- package/dist/code-mode/sessions.d.ts +53 -0
- package/dist/code-mode/tool.d.ts +5 -0
- package/dist/code-mode/types.d.ts +30 -0
- package/dist/code-mode.js +3 -1
- package/dist/{completion-BC4BNWo0.js → completion-CzHdM9B_.js} +1 -1
- package/dist/index.js +93 -28
- package/dist/native/options.d.ts +3 -6
- package/dist/native/remote.d.ts +2 -0
- package/dist/native/service.d.ts +1 -0
- package/dist/native/tools.d.ts +1 -0
- package/dist/native.js +1 -1
- package/dist/remote/options.d.ts +1 -1
- package/dist/serve/session.d.ts +1 -0
- package/dist/{service-CSRCJfpA.js → service-BCT_Ls_3.js} +2175 -182
- package/package.json +1 -1
package/dist/cli/code-mode.d.ts
CHANGED
|
@@ -6,11 +6,14 @@ export type CodeModeCliOptions = {
|
|
|
6
6
|
inlineCode?: string | undefined;
|
|
7
7
|
file?: string | undefined;
|
|
8
8
|
timeoutMs?: number | undefined;
|
|
9
|
+
sessionId?: string | undefined;
|
|
10
|
+
recoveryRef?: string | undefined;
|
|
9
11
|
json?: boolean | undefined;
|
|
10
12
|
readStdin?: (() => Promise<string>) | undefined;
|
|
11
13
|
writeOut: (value: string) => void;
|
|
12
14
|
setExitCode: (code: number) => void;
|
|
13
15
|
};
|
|
14
16
|
export declare function runCodeModeCli(options: CodeModeCliOptions): Promise<void>;
|
|
17
|
+
export declare function runCodeModeReplCli(options: Pick<CodeModeCliOptions, "env" | "configPath" | "projectConfigPath" | "authDir" | "sessionId" | "recoveryRef" | "json" | "writeOut" | "setExitCode">): Promise<void>;
|
|
15
18
|
export declare function codeModeTypesCli(options: Pick<CodeModeCliOptions, "env" | "configPath" | "projectConfigPath" | "authDir" | "json" | "writeOut">): Promise<void>;
|
|
16
19
|
export declare function readCodeModeCliCode(options: Pick<CodeModeCliOptions, "inlineCode" | "file" | "readStdin">): Promise<string>;
|
package/dist/code-mode/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NativeCapletsService } from "../native/service";
|
|
2
|
-
import type { CapletsResult, CodeModeCallableCaplet, Page, PageInput, ReadLogsInput, ReadLogsResult, ToolCallResult } from "./types";
|
|
2
|
+
import type { CapletsResult, CodeModeCallableCaplet, Page, PageInput, ReadCodeModeRecoveryInput, ReadCodeModeRecoveryResult, ReadLogsInput, ReadLogsResult, ToolCallResult } from "./types";
|
|
3
3
|
export type CodeModeCapletHandle = {
|
|
4
4
|
readonly id: string;
|
|
5
5
|
inspect(): Promise<unknown>;
|
|
@@ -19,6 +19,7 @@ export type CodeModeCapletHandle = {
|
|
|
19
19
|
};
|
|
20
20
|
export type CodeModeDebugApi = {
|
|
21
21
|
readLogs(input: ReadLogsInput): Promise<ReadLogsResult>;
|
|
22
|
+
readRecovery(input: ReadCodeModeRecoveryInput): Promise<ReadCodeModeRecoveryResult>;
|
|
22
23
|
};
|
|
23
24
|
export type CodeModeCapletsApi = {
|
|
24
25
|
[capletId: string]: CodeModeCapletHandle | CodeModeDebugApi | (CodeModeCapletHandle & CodeModeDebugApi);
|
|
@@ -27,6 +28,7 @@ export type CodeModeCapletsApi = {
|
|
|
27
28
|
export type CreateCodeModeCapletsApiInput = {
|
|
28
29
|
service: NativeCapletsService;
|
|
29
30
|
readLogs?: (input: ReadLogsInput) => Promise<ReadLogsResult>;
|
|
31
|
+
readRecovery?: (input: ReadCodeModeRecoveryInput) => Promise<ReadCodeModeRecoveryResult>;
|
|
30
32
|
};
|
|
31
33
|
export declare function listCodeModeCallableCaplets(service: NativeCapletsService): CodeModeCallableCaplet[];
|
|
32
34
|
export declare function createCodeModeCapletsApi(input: CreateCodeModeCapletsApiInput): CodeModeCapletsApi;
|
|
@@ -4,5 +4,13 @@ export type DiagnoseCodeModeTypeScriptInput = {
|
|
|
4
4
|
declaration: string;
|
|
5
5
|
maxDiagnostics?: number;
|
|
6
6
|
timeoutMs?: number;
|
|
7
|
+
session?: CodeModeDiagnosticsSession;
|
|
7
8
|
};
|
|
8
9
|
export declare function diagnoseCodeModeTypeScript(input: DiagnoseCodeModeTypeScriptInput): CodeModeDiagnostic[];
|
|
10
|
+
export declare class CodeModeDiagnosticsSession {
|
|
11
|
+
#private;
|
|
12
|
+
declaration(): string;
|
|
13
|
+
recordSuccessfulCell(code: string, declaration?: string): void;
|
|
14
|
+
clear(): void;
|
|
15
|
+
private declarationExcluding;
|
|
16
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { codeModeDeclarationHash, generateCodeModeDeclarations, generateCodeModeRunToolDescription, minifyCodeModeDeclarationText, } from "./declarations";
|
|
2
2
|
export { hasDirectFetchCall, hasExecutableImport } from "./static-analysis";
|
|
3
|
-
export type { CodeModeCallableCaplet, CodeModeDeclarationInput, CodeModeDiagnostic, CodeModeLogEntry, CodeModeLogs, CodeModeRunEnvelope, CodeModeRunError, CodeModeRunMeta, CodeModeTypesJson, JsonPrimitive, JsonValue, ReadLogsInput, ReadLogsResult, ToolCallError, ToolCallMeta, ToolCallResult, } from "./types";
|
|
3
|
+
export type { CodeModeCallableCaplet, CodeModeDeclarationInput, CodeModeDiagnostic, CodeModeLogEntry, CodeModeLogs, CodeModeRecoveryClassification, CodeModeRecoveryEntry, CodeModeRunEnvelope, CodeModeRunError, CodeModeRunMeta, CodeModeSessionStatus, CodeModeTypesJson, JsonPrimitive, JsonValue, ReadCodeModeRecoveryInput, ReadCodeModeRecoveryResult, ReadLogsInput, ReadLogsResult, ToolCallError, ToolCallMeta, ToolCallResult, } from "./types";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { CodeModeDiagnostic } from "./types";
|
|
2
|
+
export type CodeModeRecoveryClassification = "setup_like" | "side_effecting" | "unknown";
|
|
3
|
+
export type CodeModeJournalOutcome = {
|
|
4
|
+
ok: true;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export type CodeModeJournalEntry = {
|
|
11
|
+
timestamp: string;
|
|
12
|
+
code: string;
|
|
13
|
+
declarationHash: string;
|
|
14
|
+
outcome: CodeModeJournalOutcome;
|
|
15
|
+
diagnostics: Array<Pick<CodeModeDiagnostic, "code" | "severity" | "message">>;
|
|
16
|
+
recoveryClassification: CodeModeRecoveryClassification;
|
|
17
|
+
logsStored?: boolean;
|
|
18
|
+
summary?: string;
|
|
19
|
+
};
|
|
20
|
+
export type StoreCodeModeJournalEntryInput = {
|
|
21
|
+
sessionId: string;
|
|
22
|
+
journalScope?: string;
|
|
23
|
+
code: string;
|
|
24
|
+
declarationHash: string;
|
|
25
|
+
outcome: CodeModeJournalOutcome;
|
|
26
|
+
diagnostics: CodeModeDiagnostic[];
|
|
27
|
+
recoveryClassification: CodeModeRecoveryClassification;
|
|
28
|
+
logRef?: string;
|
|
29
|
+
summary?: string;
|
|
30
|
+
};
|
|
31
|
+
export type StoreCodeModeJournalEntryResult = {
|
|
32
|
+
recoveryRef: string;
|
|
33
|
+
expiresAt: string;
|
|
34
|
+
journalKey: string;
|
|
35
|
+
};
|
|
36
|
+
export type ReadCodeModeRecoveryInput = {
|
|
37
|
+
recoveryRef: string;
|
|
38
|
+
cursor?: string;
|
|
39
|
+
limit?: number;
|
|
40
|
+
};
|
|
41
|
+
export type ReadCodeModeRecoveryResult = {
|
|
42
|
+
entries: CodeModeJournalEntry[];
|
|
43
|
+
nextCursor?: string;
|
|
44
|
+
};
|
|
45
|
+
export type CodeModeJournalLookupResult = {
|
|
46
|
+
expiresAt: string;
|
|
47
|
+
recoveryRef?: string;
|
|
48
|
+
};
|
|
49
|
+
export type CodeModeJournalStoreOptions = {
|
|
50
|
+
stateDir?: string;
|
|
51
|
+
now?: () => Date;
|
|
52
|
+
retentionMs?: number;
|
|
53
|
+
maxEntries?: number;
|
|
54
|
+
maxCodeBytes?: number;
|
|
55
|
+
maxSummaryBytes?: number;
|
|
56
|
+
secret?: string;
|
|
57
|
+
};
|
|
58
|
+
export declare class CodeModeJournalStore {
|
|
59
|
+
private readonly stateDir;
|
|
60
|
+
private readonly now;
|
|
61
|
+
private readonly retentionMs;
|
|
62
|
+
private readonly maxEntries;
|
|
63
|
+
private readonly maxCodeBytes;
|
|
64
|
+
private readonly maxSummaryBytes;
|
|
65
|
+
private readonly configuredSecret;
|
|
66
|
+
private secret;
|
|
67
|
+
private recoveryRefs;
|
|
68
|
+
private sessionRecoveryRefs;
|
|
69
|
+
private nextPruneAt;
|
|
70
|
+
constructor(options?: CodeModeJournalStoreOptions);
|
|
71
|
+
store(input: StoreCodeModeJournalEntryInput): Promise<StoreCodeModeJournalEntryResult>;
|
|
72
|
+
lookupSession(sessionId: string): Promise<CodeModeJournalLookupResult | undefined>;
|
|
73
|
+
lookupRecoveryRef(recoveryRef: string): Promise<CodeModeJournalLookupResult | undefined>;
|
|
74
|
+
readRecovery(input: ReadCodeModeRecoveryInput): Promise<ReadCodeModeRecoveryResult>;
|
|
75
|
+
private entryFromInput;
|
|
76
|
+
private findByRecoveryRefHash;
|
|
77
|
+
private findBySessionIdHash;
|
|
78
|
+
private findByRecoveryRefHashSlow;
|
|
79
|
+
private findBySessionIdHashSlow;
|
|
80
|
+
private writeIndex;
|
|
81
|
+
private readIndexPath;
|
|
82
|
+
private readJournalPath;
|
|
83
|
+
private writeJournal;
|
|
84
|
+
private pruneExpired;
|
|
85
|
+
private isExpired;
|
|
86
|
+
private journalKey;
|
|
87
|
+
private recoveryRefHash;
|
|
88
|
+
private recoveryRefForJournalKey;
|
|
89
|
+
private sessionIdHash;
|
|
90
|
+
private hmac;
|
|
91
|
+
private loadSecret;
|
|
92
|
+
private ensureJournalDir;
|
|
93
|
+
private journalDir;
|
|
94
|
+
private journalPath;
|
|
95
|
+
private recoveryIndexPath;
|
|
96
|
+
private sessionIndexPath;
|
|
97
|
+
private secretPath;
|
|
98
|
+
}
|
|
99
|
+
export declare function classifyCodeModeRecovery(input: {
|
|
100
|
+
code: string;
|
|
101
|
+
invokedCaplet: boolean;
|
|
102
|
+
sessionDisposedAfterRun?: boolean;
|
|
103
|
+
}): CodeModeRecoveryClassification;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { NativeCapletsService } from "../native/service";
|
|
2
2
|
import { CodeModeLogStore } from "./logs";
|
|
3
|
+
import { CodeModeJournalStore } from "./journal";
|
|
3
4
|
import { type CodeModeSandbox } from "./sandbox";
|
|
5
|
+
import { type CodeModeSessionManager } from "./sessions";
|
|
4
6
|
import type { CodeModeRunEnvelope } from "./types";
|
|
5
7
|
export type RunCodeModeInput = {
|
|
6
8
|
code: string;
|
|
@@ -8,8 +10,11 @@ export type RunCodeModeInput = {
|
|
|
8
10
|
timeoutMs?: number;
|
|
9
11
|
maxTimeoutMs?: number;
|
|
10
12
|
runtimeScope?: string;
|
|
13
|
+
sessionId?: string;
|
|
11
14
|
logStore?: CodeModeLogStore;
|
|
15
|
+
journalStore?: CodeModeJournalStore;
|
|
12
16
|
sandbox?: CodeModeSandbox;
|
|
17
|
+
sessionManager?: CodeModeSessionManager;
|
|
13
18
|
returnedLogBytes?: number;
|
|
14
19
|
};
|
|
15
20
|
export declare function runCodeMode(input: RunCodeModeInput): Promise<CodeModeRunEnvelope>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CODE_MODE_RUNTIME_API_DECLARATION: "type JsonPrimitive=string|number|boolean|null;type JsonValue=JsonPrimitive|JsonValue[]|{[key:string]:JsonValue};interface CapletHandle<Id extends string>{readonly id:Id;/** Show this Caplet card,without tool/resource/prompt schemas. */ inspect():Promise<CapletCard<Id>>;/** Check backend readiness/auth;expected unavailable states return ok:false. */ check():Promise<CapletsResult<BackendCheckResult>>;/** List tool summaries for the discovery pass;may be empty. */ tools(input?:PageInput):Promise<Page<ToolSummary>>;/** Search tool summaries for the discovery pass;may be empty. */ searchTools(query:string,input?:PageInput):Promise<Page<ToolSummary>>;/** Get schema,callSignature,types,examples;prefer outputSchema/outputTypeScript over observed hints. */ describeTool(name:string):Promise<CapletsResult<ToolDescriptor>>;/** Call one tool;expected failures return ok:false. Filter bulky data in script before returning. */ callTool(name:string,args?:unknown):Promise<CapletsResult<unknown>>;/** List readable resources for the discovery pass;many backends expose none. */ resources(input?:PageInput):Promise<Page<ResourceSummary>>;/** Search readable resources for the discovery pass;many backends expose none. */ searchResources(query:string,input?:PageInput):Promise<Page<ResourceSummary>>;/** List resource templates for the discovery pass;many backends expose none. */ resourceTemplates(input?:PageInput):Promise<Page<ResourceTemplateSummary>>;/** Read one resource by URI;unsupported/missing resources return ok:false. */ readResource(uri:string):Promise<CapletsResult<ResourceReadResult>>;/** List reusable prompts for the discovery pass;many backends expose none. */ prompts(input?:PageInput):Promise<Page<PromptSummary>>;/** Search reusable prompts for the discovery pass;many backends expose none. */ searchPrompts(query:string,input?:PageInput):Promise<Page<PromptSummary>>;/** Get one prompt by name and args;unsupported/missing prompts return ok:false. */ getPrompt(name:string,args?:unknown):Promise<CapletsResult<PromptResult>>;/** Complete a prompt or resource-template argument. */ complete(input:CompleteInput):Promise<CapletsResult<CompleteResult>>;}interface DebugApi{readLogs(input:ReadLogsInput):Promise<ReadLogsResult>;}type CapletCard<Id extends string>={id:Id;name:string;description:string;useWhen?:string;avoidWhen?:string;tags?:string[];backend?:unknown;};type PageInput={limit?:number;cursor?:string};type Page<T>={items:T[];nextCursor?:string;truncated?:boolean};type CapletsResult<T>=|{ok:true;data:T;meta?:CapletsMeta}|{ok:false;error:CapletsError;meta?:CapletsMeta};type CapletsMeta={[key:string]:unknown};type CapletsError={code:string;message:string;details?:unknown};type BackendCheckResult=unknown;type ToolSummary={/** Exact downstream tool identifier for describeTool(name)and callTool(name,args). */ name:string;title?:string;description?:string;/** Optional author-supplied hint for when to prefer this tool. */ useWhen?:string;/** Optional author-supplied hint for when to avoid this tool. */ avoidWhen?:string;/** True when the tool declares that it only reads data. */ readOnlyHint?:boolean;/** True when the tool declares that it may perform destructive writes. */ destructiveHint?:boolean;};type ToolDescriptor={id?:string;tool?:unknown;inputSchema?:unknown;outputSchema?:unknown;callSignature?:string;inputTypeScript?:string;outputTypeScript?:string;observedOutputShape?:ObservedOutputShape;examples?:unknown[];};type ObservedOutputShape={version:1;source:\"observed\";observedAt:string;sampleCount:number;typeScript:string;jsonShape:JsonShape;truncated:boolean;};type JsonShape=|{kind:\"null\"}|{kind:\"boolean\"}|{kind:\"number\"}|{kind:\"string\"}|{kind:\"unknown\"}|{kind:\"array\";element?:JsonShape;truncated?:boolean}|{kind:\"object\";fields:Record<string,{optional:boolean;shape:JsonShape}>;truncated?:boolean;}|{kind:\"union\";variants:JsonShape[]};type ResourceSummary={uri?:string;name?:string;title?:string;description?:string};type ResourceTemplateSummary={uriTemplate?:string;name?:string;title?:string;description?:string;};type ResourceReadResult=unknown;type PromptSummary={name?:string;title?:string;description?:string};type PromptResult=unknown;type CompleteInput={ref:{type:\"prompt\";name:string}|{type:\"resourceTemplate\";uri:string};argument:{name:string;value:string};};type CompleteResult=unknown;type ReadLogsInput={logRef:string;cursor?:string;limit?:number};type ReadLogsResult={entries:CodeModeLogEntry[];nextCursor?:string};type CodeModeLogEntry={level:\"log\"|\"info\"|\"warn\"|\"error\"|\"debug\";message:string;timestamp:string;};interface Console{log(...values:unknown[]):void;info(...values:unknown[]):void;warn(...values:unknown[]):void;error(...values:unknown[]):void;debug(...values:unknown[]):void;}declare const console:Console;";
|
|
1
|
+
export declare const CODE_MODE_RUNTIME_API_DECLARATION: "type JsonPrimitive=string|number|boolean|null;type JsonValue=JsonPrimitive|JsonValue[]|{[key:string]:JsonValue};interface CapletHandle<Id extends string>{readonly id:Id;/** Show this Caplet card,without tool/resource/prompt schemas. */ inspect():Promise<CapletCard<Id>>;/** Check backend readiness/auth;expected unavailable states return ok:false. */ check():Promise<CapletsResult<BackendCheckResult>>;/** List tool summaries for the discovery pass;may be empty. */ tools(input?:PageInput):Promise<Page<ToolSummary>>;/** Search tool summaries for the discovery pass;may be empty. */ searchTools(query:string,input?:PageInput):Promise<Page<ToolSummary>>;/** Get schema,callSignature,types,examples;prefer outputSchema/outputTypeScript over observed hints. */ describeTool(name:string):Promise<CapletsResult<ToolDescriptor>>;/** Call one tool;expected failures return ok:false. Filter bulky data in script before returning. */ callTool(name:string,args?:unknown):Promise<CapletsResult<unknown>>;/** List readable resources for the discovery pass;many backends expose none. */ resources(input?:PageInput):Promise<Page<ResourceSummary>>;/** Search readable resources for the discovery pass;many backends expose none. */ searchResources(query:string,input?:PageInput):Promise<Page<ResourceSummary>>;/** List resource templates for the discovery pass;many backends expose none. */ resourceTemplates(input?:PageInput):Promise<Page<ResourceTemplateSummary>>;/** Read one resource by URI;unsupported/missing resources return ok:false. */ readResource(uri:string):Promise<CapletsResult<ResourceReadResult>>;/** List reusable prompts for the discovery pass;many backends expose none. */ prompts(input?:PageInput):Promise<Page<PromptSummary>>;/** Search reusable prompts for the discovery pass;many backends expose none. */ searchPrompts(query:string,input?:PageInput):Promise<Page<PromptSummary>>;/** Get one prompt by name and args;unsupported/missing prompts return ok:false. */ getPrompt(name:string,args?:unknown):Promise<CapletsResult<PromptResult>>;/** Complete a prompt or resource-template argument. */ complete(input:CompleteInput):Promise<CapletsResult<CompleteResult>>;}interface DebugApi{readLogs(input:ReadLogsInput):Promise<ReadLogsResult>;readRecovery(input:ReadCodeModeRecoveryInput):Promise<ReadCodeModeRecoveryResult>;}type CapletCard<Id extends string>={id:Id;name:string;description:string;useWhen?:string;avoidWhen?:string;tags?:string[];backend?:unknown;};type PageInput={limit?:number;cursor?:string};type Page<T>={items:T[];nextCursor?:string;truncated?:boolean};type CapletsResult<T>=|{ok:true;data:T;meta?:CapletsMeta}|{ok:false;error:CapletsError;meta?:CapletsMeta};type CapletsMeta={[key:string]:unknown};type CapletsError={code:string;message:string;details?:unknown};type BackendCheckResult=unknown;type ToolSummary={/** Exact downstream tool identifier for describeTool(name)and callTool(name,args). */ name:string;title?:string;description?:string;/** Optional author-supplied hint for when to prefer this tool. */ useWhen?:string;/** Optional author-supplied hint for when to avoid this tool. */ avoidWhen?:string;/** True when the tool declares that it only reads data. */ readOnlyHint?:boolean;/** True when the tool declares that it may perform destructive writes. */ destructiveHint?:boolean;};type ToolDescriptor={id?:string;tool?:unknown;inputSchema?:unknown;outputSchema?:unknown;callSignature?:string;inputTypeScript?:string;outputTypeScript?:string;observedOutputShape?:ObservedOutputShape;examples?:unknown[];};type ObservedOutputShape={version:1;source:\"observed\";observedAt:string;sampleCount:number;typeScript:string;jsonShape:JsonShape;truncated:boolean;};type JsonShape=|{kind:\"null\"}|{kind:\"boolean\"}|{kind:\"number\"}|{kind:\"string\"}|{kind:\"unknown\"}|{kind:\"array\";element?:JsonShape;truncated?:boolean}|{kind:\"object\";fields:Record<string,{optional:boolean;shape:JsonShape}>;truncated?:boolean;}|{kind:\"union\";variants:JsonShape[]};type ResourceSummary={uri?:string;name?:string;title?:string;description?:string};type ResourceTemplateSummary={uriTemplate?:string;name?:string;title?:string;description?:string;};type ResourceReadResult=unknown;type PromptSummary={name?:string;title?:string;description?:string};type PromptResult=unknown;type CompleteInput={ref:{type:\"prompt\";name:string}|{type:\"resourceTemplate\";uri:string};argument:{name:string;value:string};};type CompleteResult=unknown;type ReadLogsInput={logRef:string;cursor?:string;limit?:number};type ReadLogsResult={entries:CodeModeLogEntry[];nextCursor?:string};type ReadCodeModeRecoveryInput={recoveryRef:string;cursor?:string;limit?:number};type CodeModeDiagnostic={code:string;message:string;severity:\"error\"|\"warning\"|\"info\";line?:number;column?:number;};type CodeModeRecoveryClassification=\"setup_like\"|\"side_effecting\"|\"unknown\";type CodeModeRecoveryEntry={timestamp:string;code:string;declarationHash:string;outcome:{ok:true}|{ok:false;code:string;message:string};diagnostics:Array<Pick<CodeModeDiagnostic,\"code\"|\"severity\"|\"message\">>;recoveryClassification:CodeModeRecoveryClassification;logsStored?:boolean;summary?:string;};type ReadCodeModeRecoveryResult={entries:CodeModeRecoveryEntry[];nextCursor?:string};type CodeModeLogEntry={level:\"log\"|\"info\"|\"warn\"|\"error\"|\"debug\";message:string;timestamp:string;};type CodeModeSessionStatus=\"created\"|\"reused\";type CodeModeRunMeta={runId:string;traceId:string;declarationHash:string;durationMs:number;timeoutMs:number;maxTimeoutMs:number;sessionId?:string|null;sessionStatus?:CodeModeSessionStatus|null;recoveryRef?:string|null;};interface Console{log(...values:unknown[]):void;info(...values:unknown[]):void;warn(...values:unknown[]):void;error(...values:unknown[]):void;debug(...values:unknown[]):void;}declare const console:Console;";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type QuickJSRuntime } from "quickjs-emscripten";
|
|
1
2
|
import type { CodeModeLogEntry } from "./types";
|
|
2
3
|
export type CodeModeSandboxInvokeInput = {
|
|
3
4
|
capletId: string;
|
|
4
|
-
method: "inspect" | "check" | "tools" | "searchTools" | "describeTool" | "callTool" | "resources" | "searchResources" | "resourceTemplates" | "readResource" | "prompts" | "searchPrompts" | "getPrompt" | "complete" | "readLogs";
|
|
5
|
+
method: "inspect" | "check" | "tools" | "searchTools" | "describeTool" | "callTool" | "resources" | "searchResources" | "resourceTemplates" | "readResource" | "prompts" | "searchPrompts" | "getPrompt" | "complete" | "readLogs" | "readRecovery";
|
|
5
6
|
args: unknown[];
|
|
6
7
|
};
|
|
7
8
|
export type CodeModeSandboxInput = {
|
|
@@ -23,6 +24,18 @@ export type CodeModeSandboxResult = {
|
|
|
23
24
|
export interface CodeModeSandbox {
|
|
24
25
|
run(input: CodeModeSandboxInput): Promise<CodeModeSandboxResult>;
|
|
25
26
|
}
|
|
27
|
+
export interface CodeModeReplSession extends CodeModeSandbox {
|
|
28
|
+
dispose(): void;
|
|
29
|
+
isDisposed(): boolean;
|
|
30
|
+
}
|
|
26
31
|
export declare class QuickJsCodeModeSandbox implements CodeModeSandbox {
|
|
27
32
|
run(input: CodeModeSandboxInput): Promise<CodeModeSandboxResult>;
|
|
33
|
+
createSession(): Promise<QuickJsCodeModeReplSession>;
|
|
34
|
+
}
|
|
35
|
+
export declare class QuickJsCodeModeReplSession implements CodeModeReplSession {
|
|
36
|
+
#private;
|
|
37
|
+
constructor(runtime: QuickJSRuntime);
|
|
38
|
+
run(input: CodeModeSandboxInput): Promise<CodeModeSandboxResult>;
|
|
39
|
+
dispose(): void;
|
|
40
|
+
isDisposed(): boolean;
|
|
28
41
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type CodeModeReplSession, type CodeModeSandboxResult, type CodeModeSandboxInput } from "./sandbox";
|
|
2
|
+
import { CodeModeDiagnosticsSession } from "./diagnostics";
|
|
3
|
+
import type { CodeModeSessionStatus } from "./types";
|
|
4
|
+
export declare const CODE_MODE_SESSION_COMPATIBILITY_VERSION = 1;
|
|
5
|
+
export declare const DEFAULT_CODE_MODE_SESSION_TTL_MS: number;
|
|
6
|
+
export declare const DEFAULT_CODE_MODE_SESSION_LIMIT = 32;
|
|
7
|
+
export type CodeModeSessionCompatibility = {
|
|
8
|
+
declarationHash: string;
|
|
9
|
+
platformRuntimeHash: string;
|
|
10
|
+
runtimeScope: string;
|
|
11
|
+
version?: number;
|
|
12
|
+
};
|
|
13
|
+
export type CodeModeSessionRunInput = CodeModeSandboxInput & {
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
compatibility: CodeModeSessionCompatibility;
|
|
16
|
+
onSuccessfulCell?: (sessionId: string, code: string) => void;
|
|
17
|
+
};
|
|
18
|
+
export type CodeModeSessionRunResult = {
|
|
19
|
+
ok: true;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
sessionStatus: CodeModeSessionStatus;
|
|
22
|
+
sessionDisposedAfterRun: boolean;
|
|
23
|
+
compatibilityKey: string;
|
|
24
|
+
result: CodeModeSandboxResult;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
sessionId: string;
|
|
28
|
+
sessionStatus: null;
|
|
29
|
+
error: "not_found" | "busy" | "closed";
|
|
30
|
+
};
|
|
31
|
+
export type CodeModeSessionManagerOptions = {
|
|
32
|
+
idGenerator?: () => string;
|
|
33
|
+
now?: () => number;
|
|
34
|
+
ttlMs?: number;
|
|
35
|
+
maxSessions?: number;
|
|
36
|
+
sandboxFactory?: () => CodeModeReplSessionFactory;
|
|
37
|
+
};
|
|
38
|
+
export type CodeModeReplSessionFactory = {
|
|
39
|
+
createSession(): Promise<CodeModeReplSession>;
|
|
40
|
+
};
|
|
41
|
+
export declare class CodeModeSessionManager {
|
|
42
|
+
#private;
|
|
43
|
+
readonly ttlMs: number;
|
|
44
|
+
readonly maxSessions: number;
|
|
45
|
+
constructor(options?: CodeModeSessionManagerOptions);
|
|
46
|
+
run(input: CodeModeSessionRunInput): Promise<CodeModeSessionRunResult>;
|
|
47
|
+
close(): void;
|
|
48
|
+
has(sessionId: string): boolean;
|
|
49
|
+
compatibilityKey(sessionId: string): string | undefined;
|
|
50
|
+
diagnosticsSession(sessionId: string, compatibility: CodeModeSessionCompatibility): CodeModeDiagnosticsSession | undefined;
|
|
51
|
+
isBusy(sessionId: string, compatibility: CodeModeSessionCompatibility): boolean;
|
|
52
|
+
recordSuccessfulCell(sessionId: string, code: string, declaration?: string): void;
|
|
53
|
+
}
|
package/dist/code-mode/tool.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { CodeModeRunMeta } from "./types";
|
|
3
|
+
export declare const CODE_MODE_SESSION_ID_DESCRIPTION = "Optional Code Mode session identifier. Omit to create a fresh reusable session; pass a known live session ID from meta.sessionId to reuse existing REPL state. Unknown or unavailable session IDs fail before code execution instead of starting an empty context.";
|
|
2
4
|
export declare const codeModeRunInputSchema: z.ZodObject<{
|
|
3
5
|
code: z.ZodString;
|
|
4
6
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
5
8
|
}, z.core.$strip>;
|
|
6
9
|
export declare const codeModeRunParamsSchema: {
|
|
7
10
|
code: z.ZodString;
|
|
8
11
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
9
13
|
};
|
|
10
14
|
export declare function codeModeRunInputJsonSchema(): Record<string, unknown>;
|
|
11
15
|
export declare function isCodeModeRunRequest(value: unknown): boolean;
|
|
16
|
+
export declare function emptyCodeModeRunMeta(): CodeModeRunMeta;
|
|
@@ -27,6 +27,7 @@ export type CodeModeDiagnostic = {
|
|
|
27
27
|
line?: number;
|
|
28
28
|
column?: number;
|
|
29
29
|
};
|
|
30
|
+
export type CodeModeSessionStatus = "created" | "reused";
|
|
30
31
|
export type CodeModeRunMeta = {
|
|
31
32
|
runId: string;
|
|
32
33
|
traceId: string;
|
|
@@ -34,6 +35,9 @@ export type CodeModeRunMeta = {
|
|
|
34
35
|
durationMs: number;
|
|
35
36
|
timeoutMs: number;
|
|
36
37
|
maxTimeoutMs: number;
|
|
38
|
+
sessionId?: string | null;
|
|
39
|
+
sessionStatus?: CodeModeSessionStatus | null;
|
|
40
|
+
recoveryRef?: string | null;
|
|
37
41
|
};
|
|
38
42
|
export type CodeModeRunError = {
|
|
39
43
|
code: string;
|
|
@@ -119,3 +123,29 @@ export type ReadLogsResult = {
|
|
|
119
123
|
entries: CodeModeLogEntry[];
|
|
120
124
|
nextCursor?: string;
|
|
121
125
|
};
|
|
126
|
+
export type ReadCodeModeRecoveryInput = {
|
|
127
|
+
recoveryRef: string;
|
|
128
|
+
cursor?: string;
|
|
129
|
+
limit?: number;
|
|
130
|
+
};
|
|
131
|
+
export type CodeModeRecoveryClassification = "setup_like" | "side_effecting" | "unknown";
|
|
132
|
+
export type CodeModeRecoveryEntry = {
|
|
133
|
+
timestamp: string;
|
|
134
|
+
code: string;
|
|
135
|
+
declarationHash: string;
|
|
136
|
+
outcome: {
|
|
137
|
+
ok: true;
|
|
138
|
+
} | {
|
|
139
|
+
ok: false;
|
|
140
|
+
code: string;
|
|
141
|
+
message: string;
|
|
142
|
+
};
|
|
143
|
+
diagnostics: Array<Pick<CodeModeDiagnostic, "code" | "severity" | "message">>;
|
|
144
|
+
recoveryClassification: CodeModeRecoveryClassification;
|
|
145
|
+
logsStored?: boolean;
|
|
146
|
+
summary?: string;
|
|
147
|
+
};
|
|
148
|
+
export type ReadCodeModeRecoveryResult = {
|
|
149
|
+
entries: CodeModeRecoveryEntry[];
|
|
150
|
+
nextCursor?: string;
|
|
151
|
+
};
|
package/dist/code-mode.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region src/code-mode/runtime-api.generated.ts
|
|
5
|
-
const CODE_MODE_RUNTIME_API_DECLARATION = "type JsonPrimitive=string|number|boolean|null;type JsonValue=JsonPrimitive|JsonValue[]|{[key:string]:JsonValue};interface CapletHandle<Id extends string>{readonly id:Id;/** Show this Caplet card,without tool/resource/prompt schemas. */ inspect():Promise<CapletCard<Id>>;/** Check backend readiness/auth;expected unavailable states return ok:false. */ check():Promise<CapletsResult<BackendCheckResult>>;/** List tool summaries for the discovery pass;may be empty. */ tools(input?:PageInput):Promise<Page<ToolSummary>>;/** Search tool summaries for the discovery pass;may be empty. */ searchTools(query:string,input?:PageInput):Promise<Page<ToolSummary>>;/** Get schema,callSignature,types,examples;prefer outputSchema/outputTypeScript over observed hints. */ describeTool(name:string):Promise<CapletsResult<ToolDescriptor>>;/** Call one tool;expected failures return ok:false. Filter bulky data in script before returning. */ callTool(name:string,args?:unknown):Promise<CapletsResult<unknown>>;/** List readable resources for the discovery pass;many backends expose none. */ resources(input?:PageInput):Promise<Page<ResourceSummary>>;/** Search readable resources for the discovery pass;many backends expose none. */ searchResources(query:string,input?:PageInput):Promise<Page<ResourceSummary>>;/** List resource templates for the discovery pass;many backends expose none. */ resourceTemplates(input?:PageInput):Promise<Page<ResourceTemplateSummary>>;/** Read one resource by URI;unsupported/missing resources return ok:false. */ readResource(uri:string):Promise<CapletsResult<ResourceReadResult>>;/** List reusable prompts for the discovery pass;many backends expose none. */ prompts(input?:PageInput):Promise<Page<PromptSummary>>;/** Search reusable prompts for the discovery pass;many backends expose none. */ searchPrompts(query:string,input?:PageInput):Promise<Page<PromptSummary>>;/** Get one prompt by name and args;unsupported/missing prompts return ok:false. */ getPrompt(name:string,args?:unknown):Promise<CapletsResult<PromptResult>>;/** Complete a prompt or resource-template argument. */ complete(input:CompleteInput):Promise<CapletsResult<CompleteResult>>;}interface DebugApi{readLogs(input:ReadLogsInput):Promise<ReadLogsResult>;}type CapletCard<Id extends string>={id:Id;name:string;description:string;useWhen?:string;avoidWhen?:string;tags?:string[];backend?:unknown;};type PageInput={limit?:number;cursor?:string};type Page<T>={items:T[];nextCursor?:string;truncated?:boolean};type CapletsResult<T>=|{ok:true;data:T;meta?:CapletsMeta}|{ok:false;error:CapletsError;meta?:CapletsMeta};type CapletsMeta={[key:string]:unknown};type CapletsError={code:string;message:string;details?:unknown};type BackendCheckResult=unknown;type ToolSummary={/** Exact downstream tool identifier for describeTool(name)and callTool(name,args). */ name:string;title?:string;description?:string;/** Optional author-supplied hint for when to prefer this tool. */ useWhen?:string;/** Optional author-supplied hint for when to avoid this tool. */ avoidWhen?:string;/** True when the tool declares that it only reads data. */ readOnlyHint?:boolean;/** True when the tool declares that it may perform destructive writes. */ destructiveHint?:boolean;};type ToolDescriptor={id?:string;tool?:unknown;inputSchema?:unknown;outputSchema?:unknown;callSignature?:string;inputTypeScript?:string;outputTypeScript?:string;observedOutputShape?:ObservedOutputShape;examples?:unknown[];};type ObservedOutputShape={version:1;source:\"observed\";observedAt:string;sampleCount:number;typeScript:string;jsonShape:JsonShape;truncated:boolean;};type JsonShape=|{kind:\"null\"}|{kind:\"boolean\"}|{kind:\"number\"}|{kind:\"string\"}|{kind:\"unknown\"}|{kind:\"array\";element?:JsonShape;truncated?:boolean}|{kind:\"object\";fields:Record<string,{optional:boolean;shape:JsonShape}>;truncated?:boolean;}|{kind:\"union\";variants:JsonShape[]};type ResourceSummary={uri?:string;name?:string;title?:string;description?:string};type ResourceTemplateSummary={uriTemplate?:string;name?:string;title?:string;description?:string;};type ResourceReadResult=unknown;type PromptSummary={name?:string;title?:string;description?:string};type PromptResult=unknown;type CompleteInput={ref:{type:\"prompt\";name:string}|{type:\"resourceTemplate\";uri:string};argument:{name:string;value:string};};type CompleteResult=unknown;type ReadLogsInput={logRef:string;cursor?:string;limit?:number};type ReadLogsResult={entries:CodeModeLogEntry[];nextCursor?:string};type CodeModeLogEntry={level:\"log\"|\"info\"|\"warn\"|\"error\"|\"debug\";message:string;timestamp:string;};interface Console{log(...values:unknown[]):void;info(...values:unknown[]):void;warn(...values:unknown[]):void;error(...values:unknown[]):void;debug(...values:unknown[]):void;}declare const console:Console;";
|
|
5
|
+
const CODE_MODE_RUNTIME_API_DECLARATION = "type JsonPrimitive=string|number|boolean|null;type JsonValue=JsonPrimitive|JsonValue[]|{[key:string]:JsonValue};interface CapletHandle<Id extends string>{readonly id:Id;/** Show this Caplet card,without tool/resource/prompt schemas. */ inspect():Promise<CapletCard<Id>>;/** Check backend readiness/auth;expected unavailable states return ok:false. */ check():Promise<CapletsResult<BackendCheckResult>>;/** List tool summaries for the discovery pass;may be empty. */ tools(input?:PageInput):Promise<Page<ToolSummary>>;/** Search tool summaries for the discovery pass;may be empty. */ searchTools(query:string,input?:PageInput):Promise<Page<ToolSummary>>;/** Get schema,callSignature,types,examples;prefer outputSchema/outputTypeScript over observed hints. */ describeTool(name:string):Promise<CapletsResult<ToolDescriptor>>;/** Call one tool;expected failures return ok:false. Filter bulky data in script before returning. */ callTool(name:string,args?:unknown):Promise<CapletsResult<unknown>>;/** List readable resources for the discovery pass;many backends expose none. */ resources(input?:PageInput):Promise<Page<ResourceSummary>>;/** Search readable resources for the discovery pass;many backends expose none. */ searchResources(query:string,input?:PageInput):Promise<Page<ResourceSummary>>;/** List resource templates for the discovery pass;many backends expose none. */ resourceTemplates(input?:PageInput):Promise<Page<ResourceTemplateSummary>>;/** Read one resource by URI;unsupported/missing resources return ok:false. */ readResource(uri:string):Promise<CapletsResult<ResourceReadResult>>;/** List reusable prompts for the discovery pass;many backends expose none. */ prompts(input?:PageInput):Promise<Page<PromptSummary>>;/** Search reusable prompts for the discovery pass;many backends expose none. */ searchPrompts(query:string,input?:PageInput):Promise<Page<PromptSummary>>;/** Get one prompt by name and args;unsupported/missing prompts return ok:false. */ getPrompt(name:string,args?:unknown):Promise<CapletsResult<PromptResult>>;/** Complete a prompt or resource-template argument. */ complete(input:CompleteInput):Promise<CapletsResult<CompleteResult>>;}interface DebugApi{readLogs(input:ReadLogsInput):Promise<ReadLogsResult>;readRecovery(input:ReadCodeModeRecoveryInput):Promise<ReadCodeModeRecoveryResult>;}type CapletCard<Id extends string>={id:Id;name:string;description:string;useWhen?:string;avoidWhen?:string;tags?:string[];backend?:unknown;};type PageInput={limit?:number;cursor?:string};type Page<T>={items:T[];nextCursor?:string;truncated?:boolean};type CapletsResult<T>=|{ok:true;data:T;meta?:CapletsMeta}|{ok:false;error:CapletsError;meta?:CapletsMeta};type CapletsMeta={[key:string]:unknown};type CapletsError={code:string;message:string;details?:unknown};type BackendCheckResult=unknown;type ToolSummary={/** Exact downstream tool identifier for describeTool(name)and callTool(name,args). */ name:string;title?:string;description?:string;/** Optional author-supplied hint for when to prefer this tool. */ useWhen?:string;/** Optional author-supplied hint for when to avoid this tool. */ avoidWhen?:string;/** True when the tool declares that it only reads data. */ readOnlyHint?:boolean;/** True when the tool declares that it may perform destructive writes. */ destructiveHint?:boolean;};type ToolDescriptor={id?:string;tool?:unknown;inputSchema?:unknown;outputSchema?:unknown;callSignature?:string;inputTypeScript?:string;outputTypeScript?:string;observedOutputShape?:ObservedOutputShape;examples?:unknown[];};type ObservedOutputShape={version:1;source:\"observed\";observedAt:string;sampleCount:number;typeScript:string;jsonShape:JsonShape;truncated:boolean;};type JsonShape=|{kind:\"null\"}|{kind:\"boolean\"}|{kind:\"number\"}|{kind:\"string\"}|{kind:\"unknown\"}|{kind:\"array\";element?:JsonShape;truncated?:boolean}|{kind:\"object\";fields:Record<string,{optional:boolean;shape:JsonShape}>;truncated?:boolean;}|{kind:\"union\";variants:JsonShape[]};type ResourceSummary={uri?:string;name?:string;title?:string;description?:string};type ResourceTemplateSummary={uriTemplate?:string;name?:string;title?:string;description?:string;};type ResourceReadResult=unknown;type PromptSummary={name?:string;title?:string;description?:string};type PromptResult=unknown;type CompleteInput={ref:{type:\"prompt\";name:string}|{type:\"resourceTemplate\";uri:string};argument:{name:string;value:string};};type CompleteResult=unknown;type ReadLogsInput={logRef:string;cursor?:string;limit?:number};type ReadLogsResult={entries:CodeModeLogEntry[];nextCursor?:string};type ReadCodeModeRecoveryInput={recoveryRef:string;cursor?:string;limit?:number};type CodeModeDiagnostic={code:string;message:string;severity:\"error\"|\"warning\"|\"info\";line?:number;column?:number;};type CodeModeRecoveryClassification=\"setup_like\"|\"side_effecting\"|\"unknown\";type CodeModeRecoveryEntry={timestamp:string;code:string;declarationHash:string;outcome:{ok:true}|{ok:false;code:string;message:string};diagnostics:Array<Pick<CodeModeDiagnostic,\"code\"|\"severity\"|\"message\">>;recoveryClassification:CodeModeRecoveryClassification;logsStored?:boolean;summary?:string;};type ReadCodeModeRecoveryResult={entries:CodeModeRecoveryEntry[];nextCursor?:string};type CodeModeLogEntry={level:\"log\"|\"info\"|\"warn\"|\"error\"|\"debug\";message:string;timestamp:string;};type CodeModeSessionStatus=\"created\"|\"reused\";type CodeModeRunMeta={runId:string;traceId:string;declarationHash:string;durationMs:number;timeoutMs:number;maxTimeoutMs:number;sessionId?:string|null;sessionStatus?:CodeModeSessionStatus|null;recoveryRef?:string|null;};interface Console{log(...values:unknown[]):void;info(...values:unknown[]):void;warn(...values:unknown[]):void;error(...values:unknown[]):void;debug(...values:unknown[]):void;}declare const console:Console;";
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/code-mode/declarations.ts
|
|
8
8
|
const JS_IDENTIFIER = /^[A-Za-z_$][\w$]*$/u;
|
|
9
9
|
const MAX_JSDOC_CHARS = 180;
|
|
10
|
+
const CODE_MODE_REPL_GUIDANCE = "REPL reuse: omit `sessionId` to start a fresh reusable Code Mode session; after a successful run, keep `meta.sessionId` and pass it as `sessionId` on later calls when you want to reuse live state. Reused sessions preserve successful top-level `var` bindings, function declarations, and runtime state only while the live session remains available and compatible. A supplied `sessionId` that is unknown or no longer available fails before executing your code instead of starting an empty context. Use `meta.recoveryRef` with `caplets.debug.readRecovery({ recoveryRef })` for audit and manual reconstruction; do not automatically replay recovery history.";
|
|
10
11
|
function generateCodeModeDeclarations(input) {
|
|
11
12
|
const caplets = [...input.caplets].sort((left, right) => left.id.localeCompare(right.id));
|
|
12
13
|
const properties = caplets.map((caplet) => {
|
|
@@ -26,6 +27,7 @@ function generateCodeModeDeclarations(input) {
|
|
|
26
27
|
function generateCodeModeRunToolDescription(declaration) {
|
|
27
28
|
return [
|
|
28
29
|
"Run TypeScript with generated `caplets.<id>` handles and declaration hints below. Prefer a compact one-pass script for most tasks: discover, filter, execute, and synthesize inside Code Mode, then return only decision-ready JSON. Do not return full tool lists, full descriptors, schemas, raw tool payloads, or exploratory transcripts unless the user specifically needs them; keep bulky intermediate data inside the script. For discovery, use tools/searchTools for names and arg hints, then describeTool only for short-listed operations needing exact schemas, nested args, fields, or disambiguation. Never invent tool names, resource URIs, prompt names, input args, output fields, or schemas; use requiredArgs/acceptedArgs for simple calls, otherwise use describeTool for the exact callSignature/inputSchema/inputTypeScript. For fallback, check candidate handles first: `for(const h of candidates){const ready=await h.check();if(!ready.ok)continue;}`. For triage, list broad candidate records and filter in script before targeted searches so adjacent relevant items are not missed. Execute with exact args, handle `{ok:false}`, and derive final recommendations from all relevant records, not the first matching record. If records disagree or have ranges/statuses, compute the strictest applicable conclusion and preserve only the compact evidence used. Return summaries, key ids/names/titles/statuses/urls, derived fields, recommendation, caveats, and residual missing data. Before returning, remove unused descriptors/schemas/raw content. Pattern: `const h=caplets[\"caplet-id\"];const tools=await h.searchTools(\"query\");const d=needSchema?await h.describeTool(\"tool_name\"):undefined;const r=await h.callTool(\"tool_name\",args);return {facts:[...],evidence:[...]};`",
|
|
30
|
+
CODE_MODE_REPL_GUIDANCE,
|
|
29
31
|
"",
|
|
30
32
|
"Generated declaration hints:",
|
|
31
33
|
"```ts",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dt as resolveConfigPath, Et as resolveCapletsRoot, Tn as __exportAll, bt as DEFAULT_AUTH_DIR, kt as resolveProjectConfigPath, tt as loadConfigWithSources, xt as DEFAULT_COMPLETION_CACHE_DIR } from "./service-BCT_Ls_3.js";
|
|
2
2
|
import { u as CapletsError } from "./validation-DgxCzt-A.js";
|
|
3
3
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join } from "node:path";
|