feat(core): add agent execution context

This commit is contained in:
Yichen Jiang
2026-07-16 16:29:46 +08:00
parent 04df615dd6
commit 7bcae0cd64
93 changed files with 1272 additions and 462 deletions

View File

@@ -52,6 +52,15 @@ export interface TypeApiEntry {
/** Every harness `ctx.<key>` service, sorted by key. */
export const SERVICE_API: readonly ServiceApiEntry[] = [
{
key: 'agentExecution',
summary: 'Ambient Agent identity within one process-local asynchronous chain.',
methods: [
'current(): AgentExecution | undefined',
'require(): AgentExecution',
'run<T>(execution: AgentExecution | undefined, operation: () => T): T',
],
},
{
key: 'agentLoop',
summary: 'Concrete ReactLoopAgent factory and driver service.',
@@ -505,6 +514,10 @@ export const TYPE_API: readonly TypeApiEntry[] = [
name: 'Agent',
declaration: 'export interface Agent {\n readonly id: AgentId;\n readonly options: AgentOptions;\n readonly session: Session;\n readonly status: AgentStatus;\n readonly ctx: Context;\n send(content: ContentBlock[], options?: SendOptions): void;\n steer(content: ContentBlock[], options?: SendOptions): void;\n inject(content: ContentBlock[], options?: SendOptions): void;\n cancel(reason?: string): void;\n whenIdle(): Promise<void>;\n}',
},
{
name: 'AgentExecution',
declaration: 'export interface AgentExecution {\n readonly agent: Agent;\n}',
},
{
name: 'AgentFactory',
declaration: 'export interface AgentFactory {\n createAgent(ownerCtx: Context, options: CreateAgentOptions): Promise<AgentHandle>;\n resume(ownerCtx: Context, options: ResumeAgentOptions): Promise<AgentHandle>;\n}',