@gencode/agents 0.0.47 → 0.0.48
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/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1554,7 +1554,7 @@ declare function createApplyPatchTool(workspaceDir: string, options?: ApplyPatch
|
|
|
1554
1554
|
declare const skillsListSchema: TObject<{
|
|
1555
1555
|
category: TOptional<TString>;
|
|
1556
1556
|
}>;
|
|
1557
|
-
declare const
|
|
1557
|
+
declare const skillLoadSchema: TObject<{
|
|
1558
1558
|
name: TString;
|
|
1559
1559
|
skillPath: TOptional<TString>;
|
|
1560
1560
|
}>;
|
|
@@ -1562,7 +1562,7 @@ type SkillsListResult = {
|
|
|
1562
1562
|
skills: Array<Pick<Skill, "name" | "description">>;
|
|
1563
1563
|
count: number;
|
|
1564
1564
|
};
|
|
1565
|
-
type
|
|
1565
|
+
type SkillLoadToolResult = {
|
|
1566
1566
|
name: string;
|
|
1567
1567
|
description: string;
|
|
1568
1568
|
content: string;
|
|
@@ -1572,12 +1572,12 @@ type SkillUsedReporter = (event: Extract<AgentProgressEvent$2, {
|
|
|
1572
1572
|
type: "skill_used";
|
|
1573
1573
|
}>) => Promise<void>;
|
|
1574
1574
|
declare function createSkillsListTool(dataDir: string, pluginDirs: string[]): AgentTool<typeof skillsListSchema, SkillsListResult>;
|
|
1575
|
-
declare function
|
|
1575
|
+
declare function createSkillLoadTool(params: {
|
|
1576
1576
|
dataDir: string;
|
|
1577
1577
|
pluginDirs: string[];
|
|
1578
1578
|
sessionId: string;
|
|
1579
1579
|
reportSkillUsed?: SkillUsedReporter;
|
|
1580
|
-
}): AgentTool<typeof
|
|
1580
|
+
}): AgentTool<typeof skillLoadSchema, SkillLoadToolResult>;
|
|
1581
1581
|
//#endregion
|
|
1582
1582
|
//#region src/tools/image.d.ts
|
|
1583
1583
|
declare const imageSchema: TObject<{
|
|
@@ -2206,4 +2206,4 @@ declare function formatClarifyResolution(resolution: HitlResolution): string;
|
|
|
2206
2206
|
declare function formatReviewResolution(resolution: HitlResolution): string;
|
|
2207
2207
|
declare function buildResumeNarration(resolution: HitlResolution, kind: string): string;
|
|
2208
2208
|
//#endregion
|
|
2209
|
-
export { AgentBinding, AgentConfig, type AgentCustomProgressEvent, AgentModelConfig, type AgentProgressEvent, type AgentRunParams, type AgentRunResult, AgentsConfig, BOOTSTRAP_FILE_NAMES, BOOTSTRAP_MAX_CHARS, BOOTSTRAP_TOTAL_MAX_CHARS, type BootstrapContextFile, type BootstrapEnsureResult, type BootstrapFile, type BootstrapMountResult, type BootstrapMountStatus, type CallbackEventPayload, type CallbackPayload, type Channel, type ContextManager, DEFAULT_SESSION_STORE_NAME, type EmbeddingProvider, type EmbeddingProviderContext, type EmbeddingProviderFactory, type EmbeddingProviderRegistration, HITL_MESSAGES, type HitlPauseContext, HitlPauseSignal, type HitlToolContext, MAX_CHILDREN_PER_SESSION, MAX_SUBAGENT_DEPTH, type MemoryCallOptions, type MemoryChangeSource, type MemoryChangedEvent, type MemoryChangedHandler, MemoryIndexManager, type MemoryProvider, type MemoryProviderContext, type MemoryProviderFactory, type MemoryProviderRegistration, type MemoryProviderStatus, type MemorySearchOptions, type MemorySearchResult, type NormalizedPluginsConfig, PLUGIN_MANIFEST_FILENAME, PLUGIN_MANIFEST_FILENAMES, type PersistedSubagentRunRecord, type PersistedToolResult, type PluginApi, type PluginCandidate, type PluginConfigUiHint, type PluginCustomProgressInput, type PluginDiagnostic, type PluginDiscoveryOptions, type PluginDiscoveryResult, type PluginEntryConfig, type PluginExecutionRuntime, type PluginHookAfterCompactionEvent, type PluginHookAfterPromptBuildEvent, type PluginHookAfterToolCallEvent, type PluginHookAgentContext, type PluginHookAgentEndEvent, type PluginHookAssistantMessageEndEvent, type PluginHookBeforeCompactionEvent, type PluginHookBeforeModelResolveEvent, type PluginHookBeforeModelResolveResult, type PluginHookBeforePromptBuildEvent, type PluginHookBeforePromptBuildResult, type PluginHookBeforeToolCallEvent, type PluginHookBeforeToolCallResult, type PluginHookHandlerMap, type PluginHookLlmInputEvent, type PluginHookLlmOutputEvent, type PluginHookMemoryChangedEvent, type PluginHookName, PluginHookRegistry, type PluginHookSessionEndEvent, type PluginHookSessionResetEvent, type PluginHookSessionStartEvent, type PluginKind, type PluginManifest, type PluginManifestLoadResult, type PluginManifestRegistry, type PluginOrigin, type PluginProgressEmitter, type PluginRecord, type PluginRegistry, type PluginRuntime, type PluginRuntimeContext, type PluginSystem, type PluginSystemOptions, type PluginToolOptions, PluginToolRegistry, type PluginUiToolDescriptor, type PluginUiToolOptions, type PluginsConfig, type PluginsConfigValidationResult, type RegisteredPluginTool, type ResumeOptions, type ResumeValidationResult, type RunResultPayload, type SessionContextStore, type SessionExport, type SessionInspection, type SessionMetadata, type SessionMetadataUpdate, type SessionSummary, type Skill, type SkillDirectory, type SkillViewResult, type SlashCommandList, type SubagentContext, SubagentRegistry, type SubagentRunRecord, type SubagentStatus, type SubagentToolsContext, type SystemPromptParams, type ToolLoopDetectionConfig, type TranscriptEntry, type UiToolInputSchema, type UiToolOptions, UiToolPauseSignal, addAgent, addBinding, aimaxDir, appendToMemory, appendTranscriptEntry, approvalSummaryFromResolution, bootstrapMountLayout, buildBootstrapContextFiles, buildResumeNarration, buildSkillsPrompt, buildSubagentAnnounceMessage, buildSystemPrompt, cleanupOldSubagentRecords, clearPendingHitl, clearPendingUiTool, collapseLogPath, contextSnapshotPath, createAgentTools, createApplyPatchTool, createBashTool, createBuiltinMemoryProvider, createContextManager, createEditFileTool, createExecTool, createImageTool, createListDirTool, createMemoryAppendTool, createMemoryGetTool, createMemorySearchTool, createPendingHitl, createPendingUiTool, createPluginProgressEmitter, createPluginRuntime, createProcessTool, createReadFileTool, createSession, createSessionContextStore, createSessionsSpawnTool,
|
|
2209
|
+
export { AgentBinding, AgentConfig, type AgentCustomProgressEvent, AgentModelConfig, type AgentProgressEvent, type AgentRunParams, type AgentRunResult, AgentsConfig, BOOTSTRAP_FILE_NAMES, BOOTSTRAP_MAX_CHARS, BOOTSTRAP_TOTAL_MAX_CHARS, type BootstrapContextFile, type BootstrapEnsureResult, type BootstrapFile, type BootstrapMountResult, type BootstrapMountStatus, type CallbackEventPayload, type CallbackPayload, type Channel, type ContextManager, DEFAULT_SESSION_STORE_NAME, type EmbeddingProvider, type EmbeddingProviderContext, type EmbeddingProviderFactory, type EmbeddingProviderRegistration, HITL_MESSAGES, type HitlPauseContext, HitlPauseSignal, type HitlToolContext, MAX_CHILDREN_PER_SESSION, MAX_SUBAGENT_DEPTH, type MemoryCallOptions, type MemoryChangeSource, type MemoryChangedEvent, type MemoryChangedHandler, MemoryIndexManager, type MemoryProvider, type MemoryProviderContext, type MemoryProviderFactory, type MemoryProviderRegistration, type MemoryProviderStatus, type MemorySearchOptions, type MemorySearchResult, type NormalizedPluginsConfig, PLUGIN_MANIFEST_FILENAME, PLUGIN_MANIFEST_FILENAMES, type PersistedSubagentRunRecord, type PersistedToolResult, type PluginApi, type PluginCandidate, type PluginConfigUiHint, type PluginCustomProgressInput, type PluginDiagnostic, type PluginDiscoveryOptions, type PluginDiscoveryResult, type PluginEntryConfig, type PluginExecutionRuntime, type PluginHookAfterCompactionEvent, type PluginHookAfterPromptBuildEvent, type PluginHookAfterToolCallEvent, type PluginHookAgentContext, type PluginHookAgentEndEvent, type PluginHookAssistantMessageEndEvent, type PluginHookBeforeCompactionEvent, type PluginHookBeforeModelResolveEvent, type PluginHookBeforeModelResolveResult, type PluginHookBeforePromptBuildEvent, type PluginHookBeforePromptBuildResult, type PluginHookBeforeToolCallEvent, type PluginHookBeforeToolCallResult, type PluginHookHandlerMap, type PluginHookLlmInputEvent, type PluginHookLlmOutputEvent, type PluginHookMemoryChangedEvent, type PluginHookName, PluginHookRegistry, type PluginHookSessionEndEvent, type PluginHookSessionResetEvent, type PluginHookSessionStartEvent, type PluginKind, type PluginManifest, type PluginManifestLoadResult, type PluginManifestRegistry, type PluginOrigin, type PluginProgressEmitter, type PluginRecord, type PluginRegistry, type PluginRuntime, type PluginRuntimeContext, type PluginSystem, type PluginSystemOptions, type PluginToolOptions, PluginToolRegistry, type PluginUiToolDescriptor, type PluginUiToolOptions, type PluginsConfig, type PluginsConfigValidationResult, type RegisteredPluginTool, type ResumeOptions, type ResumeValidationResult, type RunResultPayload, type SessionContextStore, type SessionExport, type SessionInspection, type SessionMetadata, type SessionMetadataUpdate, type SessionSummary, type Skill, type SkillDirectory, type SkillViewResult, type SlashCommandList, type SubagentContext, SubagentRegistry, type SubagentRunRecord, type SubagentStatus, type SubagentToolsContext, type SystemPromptParams, type ToolLoopDetectionConfig, type TranscriptEntry, type UiToolInputSchema, type UiToolOptions, UiToolPauseSignal, addAgent, addBinding, aimaxDir, appendToMemory, appendTranscriptEntry, approvalSummaryFromResolution, bootstrapMountLayout, buildBootstrapContextFiles, buildResumeNarration, buildSkillsPrompt, buildSubagentAnnounceMessage, buildSystemPrompt, cleanupOldSubagentRecords, clearPendingHitl, clearPendingUiTool, collapseLogPath, contextSnapshotPath, createAgentTools, createApplyPatchTool, createBashTool, createBuiltinMemoryProvider, createContextManager, createEditFileTool, createExecTool, createImageTool, createListDirTool, createMemoryAppendTool, createMemoryGetTool, createMemorySearchTool, createPendingHitl, createPendingUiTool, createPluginProgressEmitter, createPluginRuntime, createProcessTool, createReadFileTool, createSession, createSessionContextStore, createSessionsSpawnTool, createSkillLoadTool, createSkillsListTool, createSubagentsTool, createUiTool, createWriteFileTool, defaultUiToolInputSchema, deleteMemoryFile, discoverAIMaxPlugins, ensureBootstrapMountLayout, ensureSession, exportSession, findSkillByName, formatApprovalResolution, formatClarifyResolution, formatReviewResolution, generateSessionTitle, getAgentConfig, getMemoryLines, hasBootstrapSentinel, hitlHistoryPath, initializePluginSystem, inspectBootstrapMountLayout, inspectSession, isBootstrapMountLayoutReady, isHitlPauseSignal, isUiToolPauseSignal, listAgents, listAvailableSlashCommands, listBindings, listMemoryFiles, listSessionSummaries, listSessions, listSubagentRunsFromDisk, loadAgentsConfig, loadBootstrapFiles, readPendingHitl as loadPendingHitl, readPendingHitl, readPendingUiTool as loadPendingUiTool, readPendingUiTool, loadPluginManifest, loadPluginManifestRegistry, loadPlugins, loadSessionContextSnapshot, loadSessionMetadata, loadSkillView, loadSkills, loadSkillsFromDirs, loadSkillsWithPluginDirs, loadSubagentRegistryFromDisk, loadTranscript, memoryDir, metadataPath, normalizeAgentId, normalizePluginsConfig, normalizeSessionStoreName, pendingHitlPath, pendingUiToolPath, primaryMemoryPath, readHitlHistory, readMemoryFile, readPrimaryMemory, registerEmbeddingProvider, registerMemoryProvider, removeAgent, removeBindings, replaceMemoryFile, resetEmbeddingProviderRegistryForTests, resetMemoryProviderRegistryForTests, resolveAgentDir, resolveAgentIdByBinding, resolveAgentsConfigPath, resolveDefaultAgentId, resolveEmbeddingProvider, resolveHitlRequest, resolveHitlRequest as resolvePendingHitl, resolveMemoryProvider, resolveModelFallbacks, resolveModelString, resolvePendingUiTool, resolvePluginManifestPath, rewriteTranscript, runAgent, saveAgentsConfig, saveSessionMetadata, saveSubagentRegistryToDisk, searchMemory, sessionDir, sessionMemoryPath, sessionsDir, skillsDir, toolResultsDir, transcriptPath, transitionHitlStatus, updateAgentIdentity, updateSessionMetadata, validatePluginsConfig, validateResume, wrapToolsWithHooks };
|
package/dist/index.js
CHANGED
|
@@ -43,15 +43,15 @@ import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,_ as s,a as c,b as l,c a
|
|
|
43
43
|
`)}function oi(e,t,n){let r=[],i=0;for(let a of n){if(a.changeContext){let n=ci(e,[a.changeContext],i,!1);if(n===null)throw Error(`Failed to find context '${a.changeContext}' in ${t}`);i=n+1}if(a.oldLines.length===0){let t=e.length>0&&e[e.length-1]===``?e.length-1:e.length;r.push([t,0,a.newLines]);continue}let n=a.oldLines,o=a.newLines,s=ci(e,n,i,a.isEndOfFile);if(s===null&&n[n.length-1]===``&&(n=n.slice(0,-1),o.length>0&&o[o.length-1]===``&&(o=o.slice(0,-1)),s=ci(e,n,i,a.isEndOfFile)),s===null)throw Error(`Failed to find expected lines in ${t}:\n${a.oldLines.join(`
|
|
44
44
|
`)}`);r.push([s,n.length,o]),i=s+n.length}return r.sort((e,t)=>e[0]-t[0]),r}function si(e,t){let n=[...e];for(let[e,r,i]of[...t].toReversed()){for(let t=0;t<r;t+=1)e<n.length&&n.splice(e,1);for(let t=0;t<i.length;t+=1)n.splice(e+t,0,i[t])}return n}function ci(e,t,n,r){if(t.length===0)return n;if(t.length>e.length)return null;let i=e.length-t.length,a=r&&e.length>=t.length?i:n;if(a>i)return null;for(let n=a;n<=i;n+=1)if(li(e,t,n,e=>e))return n;for(let n=a;n<=i;n+=1)if(li(e,t,n,e=>e.trimEnd()))return n;for(let n=a;n<=i;n+=1)if(li(e,t,n,e=>e.trim()))return n;for(let n=a;n<=i;n+=1)if(li(e,t,n,e=>ui(e.trim())))return n;return null}function li(e,t,n,r){for(let i=0;i<t.length;i+=1)if(r(e[n+i])!==r(t[i]))return!1;return!0}function ui(e){return Array.from(e).map(e=>{switch(e){case`‐`:case`‑`:case`‒`:case`–`:case`—`:case`―`:case`−`:return`-`;case`‘`:case`’`:case`‚`:case`‛`:return`'`;case`“`:case`”`:case`„`:case`‟`:return`"`;case`\xA0`:case` `:case` `:case` `:case` `:case` `:case` `:case` `:case` `:case` `:case` `:case` `:case` `:return` `;default:return e}}).join(``)}function di(e){return I.join(e,`.aimax`)}function fi(e){return I.join(di(e),`MEMORY.md`)}async function pi(e,t,n){e.onMemoryChanged&&await Promise.resolve(e.onMemoryChanged(n)).catch(()=>{}),t&&await Promise.resolve(t(n)).catch(()=>{})}function mi(e,t){let n=di(e),r=k({providerId:t?.providerId,pluginId:t?.pluginId,dataDir:e,memoryDir:n,sessionId:t?.sessionId});return r?r.provider:y({dataDir:e,memoryDir:n,sessionId:t?.sessionId})}async function hi(e){return C(di(e))}async function gi(e){try{return await F.readFile(e,`utf-8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}async function _i(e){return gi(fi(e))}async function vi(e,t,n){return await mi(e,n).search(t)}async function yi(e,t,n,r,i){try{return await mi(e,i).getLines(t,n,r)}catch{return null}}async function bi(e,t,n){let r=mi(e,n);await r.append(t),await pi(r,n?.onMemoryChanged,{reason:`append`,files:[`MEMORY.md`],source:`memory`,sessionId:n?.sessionId,providerId:n?.providerId??n?.pluginId,timestamp:new Date().toISOString()})}async function xi(e,t,n,r){let i=mi(e,r);await i.updateFile(t,n),await pi(i,r?.onMemoryChanged,{reason:`update`,files:[t],source:`memory`,sessionId:r?.sessionId,providerId:r?.providerId??r?.pluginId,timestamp:new Date().toISOString()})}async function Si(e,t,n){let r=mi(e,n);await r.deleteFile(t),await pi(r,n?.onMemoryChanged,{reason:`delete`,files:[t],source:`memory`,sessionId:n?.sessionId,providerId:n?.providerId??n?.pluginId,timestamp:new Date().toISOString()})}const Ci=L.Object({query:L.String({description:`Search query (case-insensitive substring match)`})});function wi(e,t){return{name:`memory_search`,label:`Memory Search`,description:`Search memory files for relevant information`,parameters:Ci,async execute(n,r){let i=(await vi(e,r.query,{providerId:t?.providerId,pluginId:t?.pluginId,sessionId:t?.sessionId})).map(e=>({file:e.path,start_line:e.startLine,end_line:e.endLine,score:Number(e.score.toFixed(4)),text:e.snippet,source:e.source,citation:e.citation}));return i.length===0?{content:[{type:`text`,text:`No results found for: ${r.query}`}],details:{matches:i}}:{content:[{type:`text`,text:i.map(e=>{let t=`${e.file}:${e.start_line}-${e.end_line} (${e.score}): ${e.text}`;return e.citation?`${t}\n${e.citation}`:t}).join(`
|
|
45
45
|
`)}],details:{matches:i}}}}}const Ti=L.Object({file:L.String({description:`Memory file path`}),start_line:L.Number({description:`Start line number (1-based)`}),end_line:L.Number({description:`End line number (1-based)`})});function Ei(e,t){return{name:`memory_get`,label:`Memory Get`,description:`Read specific lines from a memory file`,parameters:Ti,async execute(n,r){let i=await yi(e,r.file,r.start_line,r.end_line,{providerId:t?.providerId,pluginId:t?.pluginId,sessionId:t?.sessionId});return i===null?{content:[{type:`text`,text:`File not found: ${r.file}`}],details:{lines:null}}:{content:[{type:`text`,text:i.map((e,t)=>`${(r.start_line+t).toString().padStart(4)} ${e}`).join(`
|
|
46
|
-
`)||`(empty)`}],details:{lines:i}}}}}const Di=L.Object({content:L.String({description:`Content to append to MEMORY.md`})});function Oi(e,t){return{name:`memory_append`,label:`Memory Append`,description:`Append new information to the MEMORY.md file`,parameters:Di,async execute(n,r){try{return await bi(e,r.content,{providerId:t?.providerId,pluginId:t?.pluginId,sessionId:t?.sessionId,onMemoryChanged:t?.onMemoryChanged}),{content:[{type:`text`,text:`Memory updated.`}],details:{appended:!0}}}catch(e){return{content:[{type:`text`,text:`Error appending to memory: ${e instanceof Error?e.message:String(e)}`}],details:{appended:!1}}}}}}const ki=L.Object({category:L.Optional(L.String({description:`Reserved category filter field. Not used yet.`}))}),Ai=L.Object({name:L.String({description:`The skill name. Use skills_list first to see available skills.`}),skillPath:L.Optional(L.String({description:`Optional explicit path to a skill directory or SKILL.md. Use this for scene skills outside the shared skills registry.`}))});function ji(e,t){return[Je(e),...t]}function Mi(e,t){let n=ji(e,t);return{name:`skills_list`,label:`Skills List`,description:`List available skills with compact metadata. Use
|
|
47
|
-
`)};return{content:[{type:`text`,text:JSON.stringify(t)}],details:t}}if(i===`kill`){let n=r.target?.trim();if(!n||n===`*`||n===`all`){let n=e.killAll(t),r={action:`kill`,killed:n,text:n>0?`Killed ${n} subagent(s).`:`No running subagents to kill.`};return{content:[{type:`text`,text:JSON.stringify(r)}],details:r}}let i=zi(o,n);if(!i){let e={action:`kill`,killed:0,error:`No subagent found matching "${n}". Use list to see available subagents.`,text:`Error: no subagent matching "${n}"`};return{content:[{type:`text`,text:JSON.stringify(e)}],details:e}}let a=e.kill(i.runId),s=i.label??i.task.slice(0,40),c={action:`kill`,killed:a?1:0,text:a?`Killed subagent "${s}".`:`Subagent "${s}" is already finished.`};return{content:[{type:`text`,text:JSON.stringify(c)}],details:c}}let s={action:i,error:`Unsupported action.`,text:`Error: unsupported action.`};return{content:[{type:`text`,text:JSON.stringify(s)}],details:s}}}}const Vi=L.Object({image:L.String({description:`Image path or URL`}),prompt:L.Optional(L.String({description:`Prompt for image analysis`})),model:L.Optional(L.String({description:`Optional model override`})),maxBytesMb:L.Optional(L.Number({description:`Optional size cap in MB`}))});function Hi(){return{name:`image`,label:`Image`,description:`Analyze an image with the configured image model. (Not implemented in AIMax yet.)`,parameters:Vi,async execute(e,t){let n={implemented:!1,error:`image tool not implemented (awaiting third-party integration).`};return{content:[{type:`text`,text:`Error: ${n.error}`}],details:n}}}}var Ui=class extends Error{isUiToolPause=!0;request;constructor(e,t,n,r,i,a,o){super(`UI_TOOL_PAUSED`),this.toolArgs=o,this.name=`UiToolPauseSignal`,this.request={requestId:e,sessionId:t,toolName:n,toolCallId:r,outputSchema:i,extra:a,createdAt:new Date().toISOString()}}};function Wi(e){return!!(e instanceof Ui||typeof e==`object`&&e&&`isUiToolPause`in e&&e.isUiToolPause===!0)}const Gi=new Re;function Ki(){return{}}async function qi(e,t){return await Gi.run(e,t)}function Ji(e){let t=Gi.getStore();!t||t.signal||(t.signal=e)}const Yi=L.Object({reason:L.String({description:`A brief explanation of why user input is needed through this UI form.`})});function Xi(e){let{name:t,label:n,description:r,sessionId:i,inputSchema:a,outputSchema:o,extra:s,validate:c,resume:l}=e;return{name:t,label:n,description:r,parameters:a??Yi,async execute(e,n){if(l&&l.toolCallId===e&&l.toolName===t&&l.sessionId===i){let e=Le(o,l.values);if(!e.valid){let t=e.errors;return{content:[{type:`text`,text:JSON.stringify({error:`validation_failed`,errors:t})}],details:{}}}if(c){let e=await c(l.values);if(!e.valid){let t=e.errors;return{content:[{type:`text`,text:JSON.stringify({error:`validation_failed`,errors:t})}],details:{}}}}return{content:[{type:`text`,text:JSON.stringify({submitted:!0,values:l.values})}],details:{}}}let r=new Ui(e,i,t,e,o,s,n);throw Ji(r),r}}}function Zi(e,t){let n=I.join(e,`workspace`),r=t?.memoryOptions,i=Fr(),a=[Sr({sessionId:t?.sessionId,workspaceDir:n,registry:i,scopeKey:n,contextManager:t?.contextManager,hitlResume:t?.hitlResume}),Er({registry:i,scopeKey:n}),Vr(n,t?.contextManager),Ur(n,t?.contextManager),Gr(n,t?.contextManager),qr(n),$r(n,{sessionId:t?.sessionId,hitlResume:t?.hitlResume}),wi(e,r),Ei(e,r),Oi(e,r),Mi(e,t?.pluginSkillDirs??[]),Ni({dataDir:e,pluginDirs:t?.pluginSkillDirs??[],sessionId:t?.sessionId??`unknown`,reportSkillUsed:t?.reportSkillUsed})];return t&&a.push(Ii(t.registry,t.parentSessionId,t.depth,e,t.channel,t.llm,t.loopDetection,t.inheritedRunParams??{},t.spawnFn),Bi(t.registry,t.parentSessionId)),a}const Qi={read_file:`Read file contents`,write_file:`Create or overwrite files`,edit_file:`Make precise edits to files`,list_dir:`List directory contents`,apply_patch:`Apply multi-file patches`,exec:`Run shell commands`,process:`Manage background exec sessions`,skills_list:`List available skills with compact metadata`,
|
|
46
|
+
`)||`(empty)`}],details:{lines:i}}}}}const Di=L.Object({content:L.String({description:`Content to append to MEMORY.md`})});function Oi(e,t){return{name:`memory_append`,label:`Memory Append`,description:`Append new information to the MEMORY.md file`,parameters:Di,async execute(n,r){try{return await bi(e,r.content,{providerId:t?.providerId,pluginId:t?.pluginId,sessionId:t?.sessionId,onMemoryChanged:t?.onMemoryChanged}),{content:[{type:`text`,text:`Memory updated.`}],details:{appended:!0}}}catch(e){return{content:[{type:`text`,text:`Error appending to memory: ${e instanceof Error?e.message:String(e)}`}],details:{appended:!1}}}}}}const ki=L.Object({category:L.Optional(L.String({description:`Reserved category filter field. Not used yet.`}))}),Ai=L.Object({name:L.String({description:`The skill name. Use skills_list first to see available skills.`}),skillPath:L.Optional(L.String({description:`Optional explicit path to a skill directory or SKILL.md. Use this for scene skills outside the shared skills registry.`}))});function ji(e,t){return[Je(e),...t]}function Mi(e,t){let n=ji(e,t);return{name:`skills_list`,label:`Skills List`,description:`List available skills with compact metadata. Use skill_load to load one.`,parameters:ki,async execute(e,t){let r=await V(n),i={skills:r.map(e=>({name:e.name,description:e.description})),count:r.length};return{content:[{type:`text`,text:JSON.stringify({success:!0,...i,hint:`Use skill_load(name) to load the skill's SKILL.md entrypoint.`})}],details:i}}}}function Ni(e){let t=ji(e.dataDir,e.pluginDirs),n=new Set;return{name:`skill_load`,label:`Skill Load`,description:`Load a skill's SKILL.md entrypoint. Optionally override lookup with skillPath.`,parameters:Ai,async execute(r,i){let a=await nt(t,i.name,i.skillPath);return a?(n.has(a.skill.name)||(n.add(a.skill.name),await e.reportSkillUsed?.({type:`skill_used`,skillName:a.skill.name,agent:`aimax:main`,taskId:`aimax[${e.sessionId}]`})),{content:[{type:`text`,text:JSON.stringify({success:!0,name:a.skill.name,description:a.skill.description,content:a.content,path:a.skill.location,usage_hint:`This returns only SKILL.md. If the skill references other files, read them later with normal file tools using paths relative to the skill directory.`})}],details:{name:a.skill.name,description:a.skill.description,content:a.content,path:a.skill.location}}):{content:[{type:`text`,text:JSON.stringify({success:!1,error:i.skillPath?.trim()?`Skill '${i.name}' not found at '${i.skillPath}'.`:`Skill '${i.name}' not found.`})}],details:{name:i.name,description:``,content:``,path:``}}}}}const Pi=L.Object({task:L.String({description:`The task description for the subagent to execute`}),label:L.Optional(L.String({description:`Optional short label to identify this subagent`}))});function Fi(e){let t=e.label?`"${e.label}"`:`task: ${e.task}`;return e.status===`done`?`[Subagent completed] ${t}\n\n${e.result??`(no output)`}`:e.status===`error`?`[Subagent failed] ${t}\n\nError: ${e.error??`unknown error`}`:`[Subagent killed] ${t}`}function Ii(e,t,n,r,i,a,o,s,c){return{name:`sessions_spawn`,label:`Spawn Subagent`,description:`Use this tool only when the user or system instructions explicitly require using a subagent, delegation, or parallel agent execution. Do not use it for routine decomposition or inferred parallelism. Returns immediately with status=accepted; the subagent result will be delivered back automatically as a follow-up message — do not poll or sleep.`,parameters:Pi,async execute(l,u){let d=u.task.trim(),p=u.label?.trim();if(!d){let e={status:`error`,error:`task must not be empty`};return{content:[{type:`text`,text:JSON.stringify(e)}],details:e}}let m=e.checkSpawnAllowed(t,n+1);if(!m.allowed){let e={status:`forbidden`,error:m.reason};return{content:[{type:`text`,text:JSON.stringify(e)}],details:e}}let h=je(),g=new AbortController,_;try{_=await f(r,i,{storeName:s.sessionStoreName})}catch(e){let t={status:`error`,error:`Failed to create session: ${e instanceof Error?e.message:String(e)}`};return{content:[{type:`text`,text:JSON.stringify(t)}],details:t}}let v={runId:h,childSessionId:_,parentSessionId:t,task:d,label:p,depth:n+1,status:`running`,startedAt:Date.now(),abortController:g},y=c({dataDir:r,sessionId:_,message:d,channel:i,llm:a,...s,loopDetection:o,abortSignal:g.signal,subagentContext:{depth:n+1,parentSessionId:t}}).then(t=>{e.complete(h,t.text||t.error||`(no output)`)}).catch(t=>{let n=t instanceof Error?t.message:String(t);e.fail(h,n)});e.register(v,y);let b={status:`accepted`,childSessionId:_,runId:h,note:`The subagent result will be sent back automatically. Do not poll or re-spawn.`};return{content:[{type:`text`,text:JSON.stringify(b)}],details:b}}}}const Li=L.Object({action:L.Union([`list`,`kill`].map(e=>L.Literal(e)),{description:`Action to perform: "list" to show subagents, "kill" to stop one or all`}),target:L.Optional(L.String({description:`For kill: a runId, label, or index from the list. Use "*" or "all" to kill every subagent.`}))});function Ri(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m${Math.floor(e%6e4/1e3)}s`}function zi(e,t){let n=parseInt(t,10);return!isNaN(n)&&n>=1&&n<=e.length?e[n-1]:e.find(e=>e.runId.startsWith(t)||e.runId===t)||(e.find(e=>e.label&&e.label.toLowerCase()===t.toLowerCase())??null)}function Bi(e,t){return{name:`subagents`,label:`Subagents`,description:`List or kill subagents spawned by this session. Use list to check status, kill to stop one or all.`,parameters:Li,async execute(n,r){let i=r.action,a=Date.now(),o=e.list(t);if(i===`list`){let e=o.map((e,t)=>({index:t+1,runId:e.runId,label:e.label??e.task.slice(0,40),task:e.task,status:e.status,depth:e.depth,runtimeMs:e.endedAt?e.endedAt-e.startedAt:a-e.startedAt})),t={action:`list`,runs:e,text:(e.length===0?[`(no subagents)`]:e.map(e=>`${e.index}. [${e.status}] ${e.label} (${Ri(e.runtimeMs)})`)).join(`
|
|
47
|
+
`)};return{content:[{type:`text`,text:JSON.stringify(t)}],details:t}}if(i===`kill`){let n=r.target?.trim();if(!n||n===`*`||n===`all`){let n=e.killAll(t),r={action:`kill`,killed:n,text:n>0?`Killed ${n} subagent(s).`:`No running subagents to kill.`};return{content:[{type:`text`,text:JSON.stringify(r)}],details:r}}let i=zi(o,n);if(!i){let e={action:`kill`,killed:0,error:`No subagent found matching "${n}". Use list to see available subagents.`,text:`Error: no subagent matching "${n}"`};return{content:[{type:`text`,text:JSON.stringify(e)}],details:e}}let a=e.kill(i.runId),s=i.label??i.task.slice(0,40),c={action:`kill`,killed:a?1:0,text:a?`Killed subagent "${s}".`:`Subagent "${s}" is already finished.`};return{content:[{type:`text`,text:JSON.stringify(c)}],details:c}}let s={action:i,error:`Unsupported action.`,text:`Error: unsupported action.`};return{content:[{type:`text`,text:JSON.stringify(s)}],details:s}}}}const Vi=L.Object({image:L.String({description:`Image path or URL`}),prompt:L.Optional(L.String({description:`Prompt for image analysis`})),model:L.Optional(L.String({description:`Optional model override`})),maxBytesMb:L.Optional(L.Number({description:`Optional size cap in MB`}))});function Hi(){return{name:`image`,label:`Image`,description:`Analyze an image with the configured image model. (Not implemented in AIMax yet.)`,parameters:Vi,async execute(e,t){let n={implemented:!1,error:`image tool not implemented (awaiting third-party integration).`};return{content:[{type:`text`,text:`Error: ${n.error}`}],details:n}}}}var Ui=class extends Error{isUiToolPause=!0;request;constructor(e,t,n,r,i,a,o){super(`UI_TOOL_PAUSED`),this.toolArgs=o,this.name=`UiToolPauseSignal`,this.request={requestId:e,sessionId:t,toolName:n,toolCallId:r,outputSchema:i,extra:a,createdAt:new Date().toISOString()}}};function Wi(e){return!!(e instanceof Ui||typeof e==`object`&&e&&`isUiToolPause`in e&&e.isUiToolPause===!0)}const Gi=new Re;function Ki(){return{}}async function qi(e,t){return await Gi.run(e,t)}function Ji(e){let t=Gi.getStore();!t||t.signal||(t.signal=e)}const Yi=L.Object({reason:L.String({description:`A brief explanation of why user input is needed through this UI form.`})});function Xi(e){let{name:t,label:n,description:r,sessionId:i,inputSchema:a,outputSchema:o,extra:s,validate:c,resume:l}=e;return{name:t,label:n,description:r,parameters:a??Yi,async execute(e,n){if(l&&l.toolCallId===e&&l.toolName===t&&l.sessionId===i){let e=Le(o,l.values);if(!e.valid){let t=e.errors;return{content:[{type:`text`,text:JSON.stringify({error:`validation_failed`,errors:t})}],details:{}}}if(c){let e=await c(l.values);if(!e.valid){let t=e.errors;return{content:[{type:`text`,text:JSON.stringify({error:`validation_failed`,errors:t})}],details:{}}}}return{content:[{type:`text`,text:JSON.stringify({submitted:!0,values:l.values})}],details:{}}}let r=new Ui(e,i,t,e,o,s,n);throw Ji(r),r}}}function Zi(e,t){let n=I.join(e,`workspace`),r=t?.memoryOptions,i=Fr(),a=[Sr({sessionId:t?.sessionId,workspaceDir:n,registry:i,scopeKey:n,contextManager:t?.contextManager,hitlResume:t?.hitlResume}),Er({registry:i,scopeKey:n}),Vr(n,t?.contextManager),Ur(n,t?.contextManager),Gr(n,t?.contextManager),qr(n),$r(n,{sessionId:t?.sessionId,hitlResume:t?.hitlResume}),wi(e,r),Ei(e,r),Oi(e,r),Mi(e,t?.pluginSkillDirs??[]),Ni({dataDir:e,pluginDirs:t?.pluginSkillDirs??[],sessionId:t?.sessionId??`unknown`,reportSkillUsed:t?.reportSkillUsed})];return t&&a.push(Ii(t.registry,t.parentSessionId,t.depth,e,t.channel,t.llm,t.loopDetection,t.inheritedRunParams??{},t.spawnFn),Bi(t.registry,t.parentSessionId)),a}const Qi={read_file:`Read file contents`,write_file:`Create or overwrite files`,edit_file:`Make precise edits to files`,list_dir:`List directory contents`,apply_patch:`Apply multi-file patches`,exec:`Run shell commands`,process:`Manage background exec sessions`,skills_list:`List available skills with compact metadata`,skill_load:`Load a skill's SKILL.md entrypoint`,memory_search:`Search memory files for relevant information`,memory_get:`Read specific lines from memory files`,memory_append:`Append new long-term memory`,sessions_spawn:`Spawn an isolated subagent session`,subagents:`List, steer, or kill subagent runs`},$i=[`read_file`,`write_file`,`edit_file`,`list_dir`,`apply_patch`,`exec`,`process`,`skills_list`,`skill_load`,`memory_search`,`memory_get`,`memory_append`,`sessions_spawn`,`subagents`];function ea(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}let n=Array.from(t.keys());return{ordered:[...$i.filter(e=>t.has(e)),...n.filter(e=>!$i.includes(e)).sort()],displayName:t}}function ta(e){let{ordered:t,displayName:n}=ea(e.toolNames),r=new Map;for(let[t,n]of Object.entries(e.toolSummaries??{})){let e=t.trim().toLowerCase();!e||!n?.trim()||r.set(e,n.trim())}return[`## Tooling`,`Tool availability (filtered by runtime policy):`,`Tool names are case-sensitive. Call tools exactly as listed.`,t.map(e=>{let t=n.get(e)??e,i=r.get(e)??Qi[e];return i?`- ${t}: ${i}`:`- ${t}`}).join(`
|
|
48
48
|
`),``].join(`
|
|
49
49
|
`)}function na(){return[`## Safety`,`You have no independent goals: do not pursue self-preservation, replication, resource acquisition, or power-seeking; avoid long-term plans beyond the user's request.`,`Prioritize safety and human oversight over completion; if instructions conflict, pause and ask; comply with stop/pause/audit requests and never bypass safeguards.`,`Do not attempt to bypass approvals, safety rails, or access boundaries.`,`Never print, reveal, or echo environment variable values. If configuration must be shown, use placeholders plus brief meanings instead, such as {{API_KEY}}: model access credential.`,``].join(`
|
|
50
50
|
`)}function ra(e){return e?``:[`## Tool Call Style`,`Default: call routine low-risk tools directly without narrating every step.`,`Narrate briefly when actions are sensitive, long-running, or likely surprising.`,`When approvals are required, keep the command text exact and complete.`,``].join(`
|
|
51
|
-
`)}function ia(e){return e.length===0?``:[`## Skills (mandatory)`,`Before replying: scan <available_skills> <description> entries.`,"- If exactly one skill clearly applies: call `
|
|
51
|
+
`)}function ia(e){return e.length===0?``:[`## Skills (mandatory)`,`Before replying: scan <available_skills> <description> entries.`,"- If exactly one skill clearly applies: call `skill_load(name=<skill-name>)` for it, then follow it.","- If multiple could apply: choose the most specific one, then call `skill_load(name=<skill-name>)`.",`- If none clearly apply: do not load any skill.`,`Constraints: never load more than one skill up front.`,"The `skill_load` tool returns only the skill's `SKILL.md` entrypoint.","If that `SKILL.md` references scripts, templates, references, or assets, read those files later with normal file tools using paths relative to the skill directory.",`<available_skills>\n${e.map(e=>[` <skill>`,` <name>${e.name}</name>`,` <description>${e.description}</description>`,` <location>${e.location}</location>`,` </skill>`].join(`
|
|
52
52
|
`)).join(`
|
|
53
53
|
`)}\n</available_skills>`,``].join(`
|
|
54
|
-
`)}function aa(){return[`## Scenes`,'If the user message contains a `<scenes category="..." type="..." items="...">...</scenes>` tag, treat it as an explicit scene activation request.',"In this tag, `category` means the scene category, `type` means the scene name, and `items` means the item list required by that scene.","The `category`, `type`, and `items` attributes may each contain one or more comma-separated values. You must split them on commas, trim whitespace, and use every requested value.","Before executing the task, you must enumerate every requested `<category, scene, item>` combination derived from those attributes.","For each requested item, you must call `
|
|
54
|
+
`)}function aa(){return[`## Scenes`,'If the user message contains a `<scenes category="..." type="..." items="...">...</scenes>` tag, treat it as an explicit scene activation request.',"In this tag, `category` means the scene category, `type` means the scene name, and `items` means the item list required by that scene.","The `category`, `type`, and `items` attributes may each contain one or more comma-separated values. You must split them on commas, trim whitespace, and use every requested value.","Before executing the task, you must enumerate every requested `<category, scene, item>` combination derived from those attributes.","For each requested item, you must call `skill_load(name=<item>, skillPath=/scenes/<category>/<scene>/<item>)` to load that item's `SKILL.md`.","If one `<scenes ...>` tag requests multiple items for the same scene, you must load them one by one. Do not stop after the first matching item.","Do not start implementation, analysis, tool execution, or user-facing conclusions until all required scene skills have been loaded with `skill_load`.","After loading those scene `SKILL.md` files through `skill_load`, you must follow their instructions as mandatory task-specific guidance unless a higher-priority instruction overrides them.","Scene skills are not loaded by default. Only load them when the user explicitly includes the `<scenes ...>` tag.","Outside explicit scene activation, normal shared skills from `<available_skills>` must still be loaded with `skill_load(name=<skill-name>)` rather than direct file reads.","When a scene is activated, you must load scene instructions only through `skill_load` with `skillPath` pointing at `/scenes/<category>/<scene>/<item>` or that directory's `SKILL.md`.","Do not load, match, or fall back to scene instructions from `<dataDir>/.aimax/skills`.","Do not load, match, or fall back to scene instructions from `/aimax/extensions/`.","Do not load, match, or fall back to scene instructions from any path declared in `<available_skills>`.",`Do not ignore, rewrite, or drop the scene tag semantics even if the natural-language request looks answerable without scene skills.`,``].join(`
|
|
55
55
|
`)}function oa(){return[`## Memory Write`,`When the user asks to remember something or new long-term memory is needed, you must use memory_append. Do not use write_file or edit_file for memory writes.`,``].join(`
|
|
56
56
|
`)}function sa(e){return[`## Memory Recall`,`Before answering anything about prior work, decisions, dates, people, preferences, or todos: run memory_search on MEMORY.md + memory/*.md; then use memory_get to pull only the needed lines. If low confidence after search, say you checked.`,e===`off`?`Citations are disabled: do not include memory file paths or line numbers unless the user explicitly asks.`:`When useful, include memory evidence as Source: <path#line>.`,``].join(`
|
|
57
57
|
`)}function ca(e){let t=`${e.dataDir}/.aimax`,n=`${e.dataDir}/workspace`,r=e.sandboxInfo?.hostWorkspaceDir?.trim()||n,i=e.sandboxInfo?.containerWorkspaceDir?.trim(),a=e.sandboxInfo?.enabled&&i?`For file tools, paths resolve against the cloud workspace mount ${r}. For exec commands, use paths under ${i} (or relative paths from there). Prefer relative paths whenever possible.`:`This cloud workspace is mounted user storage. Prefer relative paths to keep file tools and shell commands aligned.`;return[`## Workspace`,`Your cloud working directory is: ${r}`,a,`User identity, memory, and agent state live under ${t}, not inside the cloud workspace.`,`Files such as AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, MEMORY.md, and the memory/ directory belong under ${t}.`,`Only create or update those files at their real .aimax paths. Never create cloud workspace copies like ${r}/AGENTS.md or ${r}/MEMORY.md unless the user explicitly asks for separate cloud documents.`,``].join(`
|
|
@@ -385,4 +385,4 @@ read_when:
|
|
|
385
385
|
`},Vs=[`AGENTS.md`,`BOOTSTRAP.md`,`IDENTITY.md`,`USER.md`,`SOUL.md`,`TOOLS.md`,`HEARTBEAT.md`];async function $(e,t){try{if(!(await F.stat(e)).isDirectory())throw Error(`Path exists but is not a directory: ${e}`);t.skippedDirs.push(e);return}catch(e){if(e.code!==`ENOENT`)throw e}await F.mkdir(e,{recursive:!0}),t.createdDirs.push(e)}async function Hs(e,t,n){try{if(!(await F.stat(e)).isFile())throw Error(`Path exists but is not a file: ${e}`);n.skippedFiles.push(e);return}catch(e){if(e.code!==`ENOENT`)throw e}await F.mkdir(I.dirname(e),{recursive:!0});try{await F.writeFile(e,t,{encoding:`utf-8`,flag:`wx`}),n.createdFiles.push(e)}catch(t){if(t.code===`EEXIST`){n.skippedFiles.push(e);return}throw t}}function Us(e){let t=B(e);return[e,t,I.join(t,`skills`),I.join(t,`sessions`),I.join(t,`memory`),I.join(e,`workspace`)]}function Ws(e){let t=B(e);return[...Vs.filter(e=>e!==`BOOTSTRAP.md`).map(e=>I.join(t,e)),I.join(t,`MEMORY.md`)]}function Gs(e){return I.join(B(e),`.bootstrapped`)}async function Ks(e){try{return(await F.stat(Gs(e))).isFile()}catch(e){if(e.code===`ENOENT`)return!1;throw e}}async function qs(e){let t=Gs(e);await F.mkdir(I.dirname(t),{recursive:!0}),await F.writeFile(t,``,{encoding:`utf-8`})}async function Js(e){let t=[],n=[];for(let n of Us(e))try{(await F.stat(n)).isDirectory()||t.push(n)}catch(e){if(e.code===`ENOENT`){t.push(n);continue}throw e}for(let t of Ws(e))try{(await F.stat(t)).isFile()||n.push(t)}catch(e){if(e.code===`ENOENT`){n.push(t);continue}throw e}return{dataDir:e,ready:t.length===0&&n.length===0,missingDirs:t,missingFiles:n}}async function Ys(e){return(await Js(e)).ready}async function Xs(e){if(await Ks(e))return{ready:!0,performedBootstrap:!1};if((await Js(e)).ready)return await qs(e),{ready:!0,performedBootstrap:!1};let t=await Zs(e);return await qs(e),{ready:!0,performedBootstrap:!0,result:t}}async function Zs(e){let t={dataDir:e,createdDirs:[],skippedDirs:[],createdFiles:[],skippedFiles:[]},n=B(e),r=I.join(e,`workspace`),i=I.join(n,`skills`),a=I.join(n,`sessions`),o=I.join(n,`memory`);await $(e,t),await $(n,t),await $(i,t),await $(a,t),await $(o,t),await $(r,t);for(let e of Vs){let r=Bs[e]??``;await Hs(I.join(n,e),r,t)}return await Hs(I.join(n,`MEMORY.md`),``,t),t}async function Qs(e){let t=I.join(e,`.aimax`,`subagents`,`runs.json`);try{let e=await F.readFile(t,`utf-8`),n=JSON.parse(e);if(!n||typeof n!=`object`)return new Map;let r;if(n.version===1&&n.records)r=n.records;else if(n.version===void 0)r=n;else return new Map;let i=new Map;for(let[e,t]of Object.entries(r)){if(!t||typeof t!=`object`)continue;let n=t;i.set(e,{...n,abortController:new AbortController})}return i}catch(e){return e.code,new Map}}async function $s(e,t){let n=I.join(e,`.aimax`,`subagents`,`runs.json`),r={};for(let[e,n]of t.entries())if(typeof n.endedAt==`number`){let{abortController:t,...i}=n;r[e]={...i,version:1}}let i={version:1,records:r};await F.mkdir(I.dirname(n),{recursive:!0}),await F.writeFile(n,JSON.stringify(i,null,2),`utf-8`)}async function ec(e,t){let n=await Qs(e),r=[];for(let e of n.values())if(e.parentSessionId===t){let{abortController:t,...n}=e;r.push({...n,version:1})}return r.sort((e,t)=>e.startedAt-t.startedAt)}async function tc(e,t=7){let n=await Qs(e),r=Date.now()-t*24*60*60*1e3,i=0;for(let[e,t]of n.entries())t.endedAt&&t.endedAt<r&&(n.delete(e),i++);return i>0&&await $s(e,n),i}async function nc(e,t,n,r){let i=await ws(e,t,{storeName:r});return i?i.request.requestId===n?i.sessionId===t?i.status===`pending`?Ie(i.request)?(await Ds(e,t,n,`expired`,void 0,{storeName:r}),{valid:!1,reason:`HITL request has expired`}):{valid:!0,state:i}:{valid:!1,reason:`HITL request is already "${i.status}", cannot resume`}:{valid:!1,reason:`Session ID mismatch: expected "${i.sessionId}", got "${t}"`}:{valid:!1,reason:`Request ID mismatch: expected "${i.request.requestId}", got "${n}"`}:{valid:!1,reason:`No pending HITL request found for this session`}}async function rc(e){let{dataDir:t,sessionId:n,requestId:r,resolution:i,sessionStoreName:a}=e,o=await Os(t,n,r,{storeName:a});if(o){let e=o.resolution?.idempotencyKey;if(e&&i.idempotencyKey&&e===i.idempotencyKey)return{state:o,idempotentReplay:!0};throw Error(`HITL resume validation failed: HITL request is already "${o.status}", cannot resume`)}let s=await nc(t,n,r,a);if(!s.valid)throw Error(`HITL resume validation failed: ${s.reason}`);let c=await Ds(t,n,r,`resolved`,i,{storeName:a});if(!c)throw Error(`Failed to transition HITL state to resolved (concurrent modification?)`);return{state:c,idempotentReplay:!1}}const ic={clarify:{label:`澄清问题`,description:`当你需要更多信息才能继续时,向用户提出澄清问题。提供清晰的问题,并可选给出候选选项。任务会暂停,直到用户回复。`,title:`需要你补充信息`,placeholder:`请输入你的回复`},approval:{label:`请求授权`,description:"仅当用户或系统明确要求调用 `request_approval` 时使用。不要把它用于一般确认、澄清或推断式授权检查。说明要执行的动作,以及为什么必须显式授权。任务会暂停,直到用户同意或拒绝。",choices:{approve:{label:`同意`,description:`允许继续执行该操作`},deny:{label:`拒绝`,description:`不允许执行该操作`}},summary:{approved:`已授权。`,denied:`已拒绝。`,timeout:`由于超时,视为拒绝。`}},review:{label:`请求审阅`,description:`在继续之前,将草稿、文档或输出提交给用户审阅。包含需要审阅的内容,以及你希望获得的反馈类型。任务会暂停,直到用户完成审阅并回复。`,choices:{approve:{label:`通过`,description:`内容没有问题,继续执行`},revise:{label:`需要修改`,description:`提供反馈后再修改`},reject:{label:`拒绝`,description:`放弃当前草稿`}}}};function ac(e){return e.action===`timeout`?ic.approval.summary.timeout:e.action===`submit`&&(e.values?.selectedChoiceIds?.includes(`approve`)??!1)?ic.approval.summary.approved:ic.approval.summary.denied}function oc(e){let t=e.action===`submit`&&(e.values?.selectedChoiceIds?.includes(`approve`)??!1);return JSON.stringify({summary:ac(e),action:e.action,approved:t,values:e.values??{},submittedBy:e.submittedBy,submittedAt:e.submittedAt,idempotencyKey:e.idempotencyKey})}function sc(e){let t=e.values?.text??e.values?.selectedChoiceIds?.join(`, `)??``;return JSON.stringify({action:e.action,answer:t,values:e.values??{},submittedBy:e.submittedBy,submittedAt:e.submittedAt})}function cc(e){let t=(e.values?.selectedChoiceIds??[])[0]??e.action,n=e.values?.text??``;return JSON.stringify({action:e.action,verdict:t,feedback:n,values:e.values??{},submittedBy:e.submittedBy,submittedAt:e.submittedAt})}function lc(e,t){let n=[];return n.push(`[HITL 恢复] 用户已响应 ${t} 请求(${e.requestId})。`),e.action===`cancel`?(n.push(`动作:用户取消了该请求。请确认取消并继续后续流程,不要执行原操作。`),n.join(`
|
|
386
386
|
`)):e.action===`timeout`?(n.push(`动作:该请求在未收到用户响应的情况下超时。请按默认超时策略处理。`),n.join(`
|
|
387
387
|
`)):(n.push(`动作:用户已提交结果。`),e.values?.selectedChoiceIds&&e.values.selectedChoiceIds.length>0&&n.push(`已选项:${e.values.selectedChoiceIds.join(`, `)}`),e.values?.text&&n.push(`用户文本:${e.values.text}`),e.values?.form&&n.push(`表单数据:${JSON.stringify(e.values.form)}`),n.join(`
|
|
388
|
-
`))}export{Ue as BOOTSTRAP_FILE_NAMES,Ve as BOOTSTRAP_MAX_CHARS,He as BOOTSTRAP_TOTAL_MAX_CHARS,u as DEFAULT_SESSION_STORE_NAME,ic as HITL_MESSAGES,fr as HitlPauseSignal,at as MAX_CHILDREN_PER_SESSION,it as MAX_SUBAGENT_DEPTH,S as MemoryIndexManager,es as PLUGIN_MANIFEST_FILENAME,ts as PLUGIN_MANIFEST_FILENAMES,ja as PluginHookRegistry,wa as PluginToolRegistry,ot as SubagentRegistry,Ui as UiToolPauseSignal,de as addAgent,se as addBinding,B as aimaxDir,bi as appendToMemory,_ as appendTranscriptEntry,ac as approvalSummaryFromResolution,Zs as bootstrapMountLayout,qe as buildBootstrapContextFiles,lc as buildResumeNarration,rt as buildSkillsPrompt,Fi as buildSubagentAnnounceMessage,ya as buildSystemPrompt,tc as cleanupOldSubagentRecords,ks as clearPendingHitl,Fs as clearPendingUiTool,w as collapseLogPath,d as contextSnapshotPath,Zi as createAgentTools,$r as createApplyPatchTool,Ir as createBashTool,y as createBuiltinMemoryProvider,ur as createContextManager,Gr as createEditFileTool,Sr as createExecTool,Hi as createImageTool,qr as createListDirTool,Oi as createMemoryAppendTool,Ei as createMemoryGetTool,wi as createMemorySearchTool,Es as createPendingHitl,Ns as createPendingUiTool,Sa as createPluginProgressEmitter,cs as createPluginRuntime,Er as createProcessTool,Vr as createReadFileTool,f as createSession,Vn as createSessionContextStore,Ii as createSessionsSpawnTool,Ni as
|
|
388
|
+
`))}export{Ue as BOOTSTRAP_FILE_NAMES,Ve as BOOTSTRAP_MAX_CHARS,He as BOOTSTRAP_TOTAL_MAX_CHARS,u as DEFAULT_SESSION_STORE_NAME,ic as HITL_MESSAGES,fr as HitlPauseSignal,at as MAX_CHILDREN_PER_SESSION,it as MAX_SUBAGENT_DEPTH,S as MemoryIndexManager,es as PLUGIN_MANIFEST_FILENAME,ts as PLUGIN_MANIFEST_FILENAMES,ja as PluginHookRegistry,wa as PluginToolRegistry,ot as SubagentRegistry,Ui as UiToolPauseSignal,de as addAgent,se as addBinding,B as aimaxDir,bi as appendToMemory,_ as appendTranscriptEntry,ac as approvalSummaryFromResolution,Zs as bootstrapMountLayout,qe as buildBootstrapContextFiles,lc as buildResumeNarration,rt as buildSkillsPrompt,Fi as buildSubagentAnnounceMessage,ya as buildSystemPrompt,tc as cleanupOldSubagentRecords,ks as clearPendingHitl,Fs as clearPendingUiTool,w as collapseLogPath,d as contextSnapshotPath,Zi as createAgentTools,$r as createApplyPatchTool,Ir as createBashTool,y as createBuiltinMemoryProvider,ur as createContextManager,Gr as createEditFileTool,Sr as createExecTool,Hi as createImageTool,qr as createListDirTool,Oi as createMemoryAppendTool,Ei as createMemoryGetTool,wi as createMemorySearchTool,Es as createPendingHitl,Ns as createPendingUiTool,Sa as createPluginProgressEmitter,cs as createPluginRuntime,Er as createProcessTool,Vr as createReadFileTool,f as createSession,Vn as createSessionContextStore,Ii as createSessionsSpawnTool,Ni as createSkillLoadTool,Mi as createSkillsListTool,Bi as createSubagentsTool,Xi as createUiTool,Ur as createWriteFileTool,Yi as defaultUiToolInputSchema,Si as deleteMemoryFile,Qo as discoverAIMaxPlugins,Xs as ensureBootstrapMountLayout,x as ensureSession,v as exportSession,et as findSkillByName,oc as formatApprovalResolution,sc as formatClarifyResolution,cc as formatReviewResolution,Ht as generateSessionTitle,ie as getAgentConfig,yi as getMemoryLines,Ks as hasBootstrapSentinel,xs as hitlHistoryPath,ms as initializePluginSystem,Js as inspectBootstrapMountLayout,m as inspectSession,Ys as isBootstrapMountLayoutReady,q as isHitlPauseSignal,Wi as isUiToolPauseSignal,N as listAgents,$t as listAvailableSlashCommands,ce as listBindings,hi as listMemoryFiles,p as listSessionSummaries,s as listSessions,ec as listSubagentRunsFromDisk,ue as loadAgentsConfig,We as loadBootstrapFiles,ws as loadPendingHitl,ws as readPendingHitl,Ms as loadPendingUiTool,Ms as readPendingUiTool,rs as loadPluginManifest,is as loadPluginManifestRegistry,ds as loadPlugins,T as loadSessionContextSnapshot,O as loadSessionMetadata,nt as loadSkillView,Qe as loadSkills,V as loadSkillsFromDirs,$e as loadSkillsWithPluginDirs,Qs as loadSubagentRegistryFromDisk,l as loadTranscript,di as memoryDir,D as metadataPath,P as normalizeAgentId,Oo as normalizePluginsConfig,a as normalizeSessionStoreName,bs as pendingHitlPath,As as pendingUiToolPath,fi as primaryMemoryPath,Ts as readHitlHistory,gi as readMemoryFile,_i as readPrimaryMemory,h as registerEmbeddingProvider,A as registerMemoryProvider,ae as removeAgent,fe as removeBindings,xi as replaceMemoryFile,c as resetEmbeddingProviderRegistryForTests,j as resetMemoryProviderRegistryForTests,ee as resolveAgentDir,te as resolveAgentIdByBinding,le as resolveAgentsConfigPath,oe as resolveDefaultAgentId,b as resolveEmbeddingProvider,rc as resolveHitlRequest,rc as resolvePendingHitl,k as resolveMemoryProvider,re as resolveModelFallbacks,ne as resolveModelString,Ps as resolvePendingUiTool,ns as resolvePluginManifestPath,t as rewriteTranscript,zs as runAgent,M as saveAgentsConfig,E as saveSessionMetadata,$s as saveSubagentRegistryToDisk,vi as searchMemory,o as sessionDir,r as sessionMemoryPath,n as sessionsDir,Je as skillsDir,i as toolResultsDir,g as transcriptPath,Ds as transitionHitlStatus,pe as updateAgentIdentity,e as updateSessionMetadata,ko as validatePluginsConfig,nc as validateResume,Aa as wrapToolsWithHooks};
|