@xenosystem/agent-sdk 0.10.37 → 0.10.39

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.
Files changed (57) hide show
  1. package/dist/artifacts/index.cjs +9 -9
  2. package/dist/artifacts/index.js +9 -9
  3. package/dist/artifacts/metafile-cjs.json +1 -1
  4. package/dist/artifacts/metafile-esm.json +1 -1
  5. package/dist/automation/index.cjs +8 -8
  6. package/dist/automation/index.d.cts +10 -0
  7. package/dist/automation/index.d.ts +10 -0
  8. package/dist/automation/index.js +9 -9
  9. package/dist/automation/metafile-cjs.json +1 -1
  10. package/dist/automation/metafile-esm.json +1 -1
  11. package/dist/control-plane/index.cjs +1 -1
  12. package/dist/control-plane/index.js +1 -1
  13. package/dist/electron/index.cjs +221 -200
  14. package/dist/electron/index.d.cts +91 -1
  15. package/dist/electron/index.d.ts +91 -1
  16. package/dist/electron/index.js +221 -200
  17. package/dist/electron/metafile-cjs.json +1 -1
  18. package/dist/electron/metafile-esm.json +1 -1
  19. package/dist/index.cjs +397 -372
  20. package/dist/index.d.cts +136 -4
  21. package/dist/index.d.ts +136 -4
  22. package/dist/index.js +397 -372
  23. package/dist/intelligence/index.cjs +9 -9
  24. package/dist/intelligence/index.js +9 -9
  25. package/dist/intelligence/metafile-cjs.json +1 -1
  26. package/dist/intelligence/metafile-esm.json +1 -1
  27. package/dist/mcp/index.d.cts +10 -0
  28. package/dist/mcp/index.d.ts +10 -0
  29. package/dist/metafile-cjs.json +1 -1
  30. package/dist/metafile-esm.json +1 -1
  31. package/dist/providers/index.cjs +9 -9
  32. package/dist/providers/index.js +9 -9
  33. package/dist/providers/metafile-cjs.json +1 -1
  34. package/dist/providers/metafile-esm.json +1 -1
  35. package/dist/recipes/index.cjs +2 -2
  36. package/dist/recipes/index.js +2 -2
  37. package/dist/recipes/metafile-cjs.json +1 -1
  38. package/dist/recipes/metafile-esm.json +1 -1
  39. package/dist/research/index.cjs +3 -3
  40. package/dist/research/index.js +3 -3
  41. package/dist/research/metafile-cjs.json +1 -1
  42. package/dist/research/metafile-esm.json +1 -1
  43. package/dist/session/index.cjs +25 -25
  44. package/dist/session/index.js +25 -25
  45. package/dist/session/metafile-cjs.json +1 -1
  46. package/dist/session/metafile-esm.json +1 -1
  47. package/dist/sharing/index.cjs +4 -4
  48. package/dist/sharing/index.js +4 -4
  49. package/dist/sharing/metafile-cjs.json +1 -1
  50. package/dist/sharing/metafile-esm.json +1 -1
  51. package/dist/utils/index.cjs +23 -23
  52. package/dist/utils/index.d.cts +15 -1
  53. package/dist/utils/index.d.ts +15 -1
  54. package/dist/utils/index.js +23 -23
  55. package/dist/utils/metafile-cjs.json +1 -1
  56. package/dist/utils/metafile-esm.json +1 -1
  57. package/package.json +3 -3
@@ -52,6 +52,64 @@ interface XenoRequestContext {
52
52
  readonly name: string;
53
53
  readonly version: string;
54
54
  };
55
+ readonly headers?: Readonly<Record<string, string>>;
56
+ }
57
+ type AgentChildOutcome = "completed" | "failed" | "timeout" | "cancelled" | "incomplete";
58
+ interface AgentChildTokenUsage {
59
+ input: number;
60
+ output: number;
61
+ total: number;
62
+ }
63
+ type BackgroundDispatchStatus = "running" | AgentChildOutcome;
64
+ interface BackgroundDispatchReport {
65
+ dispatchId: string;
66
+ agent?: string;
67
+ promptPreview: string;
68
+ outcome: AgentChildOutcome;
69
+ output?: string;
70
+ error?: string;
71
+ errorCode?: string;
72
+ reason?: string;
73
+ durationMs: number;
74
+ tokenUsage?: AgentChildTokenUsage;
75
+ }
76
+ interface BackgroundDispatchSettlement {
77
+ outcome: AgentChildOutcome;
78
+ output?: string;
79
+ error?: string;
80
+ errorCode?: string;
81
+ reason?: string;
82
+ tokenUsage?: AgentChildTokenUsage;
83
+ }
84
+ interface BackgroundDispatchRecord {
85
+ dispatchId: string;
86
+ agent?: string;
87
+ promptPreview: string;
88
+ startedAt: number;
89
+ status: BackgroundDispatchStatus;
90
+ report?: BackgroundDispatchReport;
91
+ }
92
+ interface BackgroundDispatchHandle {
93
+ readonly dispatchId: string;
94
+ settle(result: BackgroundDispatchSettlement): void;
95
+ }
96
+ interface BackgroundDispatchRegistry {
97
+ start(info: {
98
+ dispatchId: string;
99
+ agent?: string;
100
+ promptPreview: string;
101
+ }, cancel: (reason?: string) => void): BackgroundDispatchHandle;
102
+ get(dispatchId: string): BackgroundDispatchRecord | undefined;
103
+ list(): BackgroundDispatchRecord[];
104
+ wait(dispatchId: string, options?: {
105
+ timeoutMs?: number;
106
+ signal?: AbortSignal;
107
+ }): Promise<BackgroundDispatchRecord | undefined>;
108
+ cancel(dispatchId: string, reason?: string): boolean;
109
+ cancelAll(reason?: string): number;
110
+ markConsumed(dispatchId: string): void;
111
+ isConsumed(dispatchId: string): boolean;
112
+ onReport(listener: (report: BackgroundDispatchReport) => void): () => void;
55
113
  }
56
114
  type TokenEstimator = (text: string, model: string) => number;
57
115
  type TokenAccountingSource = "exact" | "provider-reported" | "estimated";
@@ -693,6 +751,11 @@ interface MemoryManagerOptions {
693
751
  maxCharsPerSession?: number;
694
752
  };
695
753
  }
754
+ interface PromptMemoryBundle {
755
+ resolved: ResolvedMemory;
756
+ projectSessionContext?: ProjectSessionContext;
757
+ prompt: string;
758
+ }
696
759
  type MemoryAccessScope = "none" | "session" | "project" | "user";
697
760
  declare class MemoryManager {
698
761
  private cwd;
@@ -719,6 +782,11 @@ declare class MemoryManager {
719
782
  maxTokens?: number;
720
783
  maxCharsPerSession?: number;
721
784
  }): Promise<ProjectSessionContext>;
785
+ private readRecentTranscriptExcerpt;
786
+ loadPromptBundle(options?: {
787
+ excludeSessionId?: string;
788
+ includeProjectSessionContext?: boolean;
789
+ }): Promise<PromptMemoryBundle>;
722
790
  private filterProjectSessions;
723
791
  private normalizePath;
724
792
  private extractRecentTranscriptExcerpt;
@@ -1085,6 +1153,8 @@ interface LlmClientDeps {
1085
1153
  declare class LlmClient {
1086
1154
  private deps;
1087
1155
  constructor(deps: LlmClientDeps);
1156
+ setRequestContext(context: Readonly<XenoRequestContext> | undefined): void;
1157
+ getRequestContext(): Readonly<XenoRequestContext> | undefined;
1088
1158
  configureAuthorization(options: Pick<LlmClientDeps, "apiKey" | "authorizeRequest">): void;
1089
1159
  private localGrammarProbe?;
1090
1160
  readonly id = "xeno-llm-client";
@@ -1235,7 +1305,7 @@ interface LLMProvider {
1235
1305
  type QueryState = "idle" | "preparing" | "building_context" | "requesting_model" | "retrying" | "executing_tools" | "waiting_for_tool" | "evaluating_completion" | "finalizing" | "suspended" | "completed" | "failed" | "interrupted";
1236
1306
  type QueryWatchdogReason = "idle" | "lease" | "hard";
1237
1307
  type ToolOperationRuntimeEventType = "tool.operation.started" | "tool.operation.progress" | "tool.operation.promotion_requested" | "tool.operation.promoted" | "tool.operation.stalled" | "tool.operation.verifying" | "tool.operation.completed" | "tool.operation.failed" | "tool.operation.timed_out" | "tool.operation.cancelled" | "tool.operation.outcome_unknown";
1238
- type XenoRuntimeEventType = "thread.started" | "turn.started" | "turn.completed" | "turn.failed" | "turn.interrupted" | "query.state" | "query.watchdog" | "provider.event" | "model.text.delta" | "context.pressure" | "context.injected" | "context.history.compacted" | "tool.started" | "tool.permission" | "tool.completed" | "tool.history.repaired" | "tool.failure_guard.tripped" | ToolOperationRuntimeEventType | "turn.suspended" | "turn.continuation_enqueued" | "turn.continuation_resumed" | "turn.continuation_exhausted" | "diff.completed";
1308
+ type XenoRuntimeEventType = "thread.started" | "turn.started" | "turn.completed" | "turn.failed" | "turn.interrupted" | "query.state" | "query.watchdog" | "provider.event" | "model.text.delta" | "context.pressure" | "context.injected" | "context.history.compacted" | "dispatch.settled" | "tool.started" | "tool.permission" | "tool.completed" | "tool.history.repaired" | "tool.failure_guard.tripped" | ToolOperationRuntimeEventType | "turn.suspended" | "turn.continuation_enqueued" | "turn.continuation_resumed" | "turn.continuation_exhausted" | "diff.completed";
1239
1309
  interface XenoRuntimeEventBase {
1240
1310
  id: string;
1241
1311
  sequence: number;
@@ -1280,6 +1350,16 @@ type XenoRuntimeEvent = (XenoRuntimeEventBase & {
1280
1350
  deferred: boolean;
1281
1351
  turnId?: string;
1282
1352
  iteration?: number;
1353
+ }) | (XenoRuntimeEventBase & {
1354
+ type: "dispatch.settled";
1355
+ dispatchId: string;
1356
+ outcome: "completed" | "failed" | "timeout" | "cancelled" | "incomplete";
1357
+ agent?: string;
1358
+ errorCode?: string;
1359
+ turnActive: boolean;
1360
+ delivery: "injected" | "queued";
1361
+ durationMs: number;
1362
+ summary: string;
1283
1363
  }) | (XenoRuntimeEventBase & {
1284
1364
  type: "context.history.compacted";
1285
1365
  turnId?: string;
@@ -1849,6 +1929,9 @@ declare class AgentLoop {
1849
1929
  private totalOutputTokens;
1850
1930
  private lastRequestInputTokens;
1851
1931
  private pendingContextInjections;
1932
+ private dispatchRegistry;
1933
+ private dispatchUnsubscribe;
1934
+ private activeRunCount;
1852
1935
  private lastCheckpointMessageCount;
1853
1936
  private ollamaBaseUrl;
1854
1937
  private activeAbortController;
@@ -1892,6 +1975,8 @@ declare class AgentLoop {
1892
1975
  createSoftBudgetCloudProvider(): LLMProvider;
1893
1976
  private callCloudWithOutputCap;
1894
1977
  private requestStreams;
1978
+ setRequestContext(context: XenoRequestContext): void;
1979
+ getRequestContext(): Readonly<XenoRequestContext> | undefined;
1895
1980
  configureModelExecution(options: {
1896
1981
  provider?: LLMProvider;
1897
1982
  modelWorkAccounting?: ModelWorkAccounting;
@@ -1913,6 +1998,8 @@ declare class AgentLoop {
1913
1998
  set executionMode(value: ExecutionMode);
1914
1999
  get systemPrompt(): string;
1915
2000
  set systemPrompt(value: string);
2001
+ private promptGate;
2002
+ holdRunUntil(gate: Promise<void>): void;
1916
2003
  use(middleware: ToolMiddleware): this;
1917
2004
  registerPromptSection(provider: PromptSectionProvider): this;
1918
2005
  registerCompletionGuard(guard: CompletionGuard): this;
@@ -1976,10 +2063,13 @@ declare class AgentLoop {
1976
2063
  content: string;
1977
2064
  sourceNodeId?: string;
1978
2065
  label?: string;
2066
+ dispatchId?: string;
1979
2067
  }): Promise<{
1980
2068
  status: "injected" | "deferred";
1981
2069
  pendingCount: number;
1982
2070
  }>;
2071
+ attachBackgroundDispatch(registry: BackgroundDispatchRegistry): () => void;
2072
+ private deliverBackgroundDispatchReport;
1983
2073
  get pendingContextInjectionCount(): number;
1984
2074
  private flushContextInjections;
1985
2075
  get messages(): Message[];
@@ -52,6 +52,64 @@ interface XenoRequestContext {
52
52
  readonly name: string;
53
53
  readonly version: string;
54
54
  };
55
+ readonly headers?: Readonly<Record<string, string>>;
56
+ }
57
+ type AgentChildOutcome = "completed" | "failed" | "timeout" | "cancelled" | "incomplete";
58
+ interface AgentChildTokenUsage {
59
+ input: number;
60
+ output: number;
61
+ total: number;
62
+ }
63
+ type BackgroundDispatchStatus = "running" | AgentChildOutcome;
64
+ interface BackgroundDispatchReport {
65
+ dispatchId: string;
66
+ agent?: string;
67
+ promptPreview: string;
68
+ outcome: AgentChildOutcome;
69
+ output?: string;
70
+ error?: string;
71
+ errorCode?: string;
72
+ reason?: string;
73
+ durationMs: number;
74
+ tokenUsage?: AgentChildTokenUsage;
75
+ }
76
+ interface BackgroundDispatchSettlement {
77
+ outcome: AgentChildOutcome;
78
+ output?: string;
79
+ error?: string;
80
+ errorCode?: string;
81
+ reason?: string;
82
+ tokenUsage?: AgentChildTokenUsage;
83
+ }
84
+ interface BackgroundDispatchRecord {
85
+ dispatchId: string;
86
+ agent?: string;
87
+ promptPreview: string;
88
+ startedAt: number;
89
+ status: BackgroundDispatchStatus;
90
+ report?: BackgroundDispatchReport;
91
+ }
92
+ interface BackgroundDispatchHandle {
93
+ readonly dispatchId: string;
94
+ settle(result: BackgroundDispatchSettlement): void;
95
+ }
96
+ interface BackgroundDispatchRegistry {
97
+ start(info: {
98
+ dispatchId: string;
99
+ agent?: string;
100
+ promptPreview: string;
101
+ }, cancel: (reason?: string) => void): BackgroundDispatchHandle;
102
+ get(dispatchId: string): BackgroundDispatchRecord | undefined;
103
+ list(): BackgroundDispatchRecord[];
104
+ wait(dispatchId: string, options?: {
105
+ timeoutMs?: number;
106
+ signal?: AbortSignal;
107
+ }): Promise<BackgroundDispatchRecord | undefined>;
108
+ cancel(dispatchId: string, reason?: string): boolean;
109
+ cancelAll(reason?: string): number;
110
+ markConsumed(dispatchId: string): void;
111
+ isConsumed(dispatchId: string): boolean;
112
+ onReport(listener: (report: BackgroundDispatchReport) => void): () => void;
55
113
  }
56
114
  type TokenEstimator = (text: string, model: string) => number;
57
115
  type TokenAccountingSource = "exact" | "provider-reported" | "estimated";
@@ -693,6 +751,11 @@ interface MemoryManagerOptions {
693
751
  maxCharsPerSession?: number;
694
752
  };
695
753
  }
754
+ interface PromptMemoryBundle {
755
+ resolved: ResolvedMemory;
756
+ projectSessionContext?: ProjectSessionContext;
757
+ prompt: string;
758
+ }
696
759
  type MemoryAccessScope = "none" | "session" | "project" | "user";
697
760
  declare class MemoryManager {
698
761
  private cwd;
@@ -719,6 +782,11 @@ declare class MemoryManager {
719
782
  maxTokens?: number;
720
783
  maxCharsPerSession?: number;
721
784
  }): Promise<ProjectSessionContext>;
785
+ private readRecentTranscriptExcerpt;
786
+ loadPromptBundle(options?: {
787
+ excludeSessionId?: string;
788
+ includeProjectSessionContext?: boolean;
789
+ }): Promise<PromptMemoryBundle>;
722
790
  private filterProjectSessions;
723
791
  private normalizePath;
724
792
  private extractRecentTranscriptExcerpt;
@@ -1085,6 +1153,8 @@ interface LlmClientDeps {
1085
1153
  declare class LlmClient {
1086
1154
  private deps;
1087
1155
  constructor(deps: LlmClientDeps);
1156
+ setRequestContext(context: Readonly<XenoRequestContext> | undefined): void;
1157
+ getRequestContext(): Readonly<XenoRequestContext> | undefined;
1088
1158
  configureAuthorization(options: Pick<LlmClientDeps, "apiKey" | "authorizeRequest">): void;
1089
1159
  private localGrammarProbe?;
1090
1160
  readonly id = "xeno-llm-client";
@@ -1235,7 +1305,7 @@ interface LLMProvider {
1235
1305
  type QueryState = "idle" | "preparing" | "building_context" | "requesting_model" | "retrying" | "executing_tools" | "waiting_for_tool" | "evaluating_completion" | "finalizing" | "suspended" | "completed" | "failed" | "interrupted";
1236
1306
  type QueryWatchdogReason = "idle" | "lease" | "hard";
1237
1307
  type ToolOperationRuntimeEventType = "tool.operation.started" | "tool.operation.progress" | "tool.operation.promotion_requested" | "tool.operation.promoted" | "tool.operation.stalled" | "tool.operation.verifying" | "tool.operation.completed" | "tool.operation.failed" | "tool.operation.timed_out" | "tool.operation.cancelled" | "tool.operation.outcome_unknown";
1238
- type XenoRuntimeEventType = "thread.started" | "turn.started" | "turn.completed" | "turn.failed" | "turn.interrupted" | "query.state" | "query.watchdog" | "provider.event" | "model.text.delta" | "context.pressure" | "context.injected" | "context.history.compacted" | "tool.started" | "tool.permission" | "tool.completed" | "tool.history.repaired" | "tool.failure_guard.tripped" | ToolOperationRuntimeEventType | "turn.suspended" | "turn.continuation_enqueued" | "turn.continuation_resumed" | "turn.continuation_exhausted" | "diff.completed";
1308
+ type XenoRuntimeEventType = "thread.started" | "turn.started" | "turn.completed" | "turn.failed" | "turn.interrupted" | "query.state" | "query.watchdog" | "provider.event" | "model.text.delta" | "context.pressure" | "context.injected" | "context.history.compacted" | "dispatch.settled" | "tool.started" | "tool.permission" | "tool.completed" | "tool.history.repaired" | "tool.failure_guard.tripped" | ToolOperationRuntimeEventType | "turn.suspended" | "turn.continuation_enqueued" | "turn.continuation_resumed" | "turn.continuation_exhausted" | "diff.completed";
1239
1309
  interface XenoRuntimeEventBase {
1240
1310
  id: string;
1241
1311
  sequence: number;
@@ -1280,6 +1350,16 @@ type XenoRuntimeEvent = (XenoRuntimeEventBase & {
1280
1350
  deferred: boolean;
1281
1351
  turnId?: string;
1282
1352
  iteration?: number;
1353
+ }) | (XenoRuntimeEventBase & {
1354
+ type: "dispatch.settled";
1355
+ dispatchId: string;
1356
+ outcome: "completed" | "failed" | "timeout" | "cancelled" | "incomplete";
1357
+ agent?: string;
1358
+ errorCode?: string;
1359
+ turnActive: boolean;
1360
+ delivery: "injected" | "queued";
1361
+ durationMs: number;
1362
+ summary: string;
1283
1363
  }) | (XenoRuntimeEventBase & {
1284
1364
  type: "context.history.compacted";
1285
1365
  turnId?: string;
@@ -1849,6 +1929,9 @@ declare class AgentLoop {
1849
1929
  private totalOutputTokens;
1850
1930
  private lastRequestInputTokens;
1851
1931
  private pendingContextInjections;
1932
+ private dispatchRegistry;
1933
+ private dispatchUnsubscribe;
1934
+ private activeRunCount;
1852
1935
  private lastCheckpointMessageCount;
1853
1936
  private ollamaBaseUrl;
1854
1937
  private activeAbortController;
@@ -1892,6 +1975,8 @@ declare class AgentLoop {
1892
1975
  createSoftBudgetCloudProvider(): LLMProvider;
1893
1976
  private callCloudWithOutputCap;
1894
1977
  private requestStreams;
1978
+ setRequestContext(context: XenoRequestContext): void;
1979
+ getRequestContext(): Readonly<XenoRequestContext> | undefined;
1895
1980
  configureModelExecution(options: {
1896
1981
  provider?: LLMProvider;
1897
1982
  modelWorkAccounting?: ModelWorkAccounting;
@@ -1913,6 +1998,8 @@ declare class AgentLoop {
1913
1998
  set executionMode(value: ExecutionMode);
1914
1999
  get systemPrompt(): string;
1915
2000
  set systemPrompt(value: string);
2001
+ private promptGate;
2002
+ holdRunUntil(gate: Promise<void>): void;
1916
2003
  use(middleware: ToolMiddleware): this;
1917
2004
  registerPromptSection(provider: PromptSectionProvider): this;
1918
2005
  registerCompletionGuard(guard: CompletionGuard): this;
@@ -1976,10 +2063,13 @@ declare class AgentLoop {
1976
2063
  content: string;
1977
2064
  sourceNodeId?: string;
1978
2065
  label?: string;
2066
+ dispatchId?: string;
1979
2067
  }): Promise<{
1980
2068
  status: "injected" | "deferred";
1981
2069
  pendingCount: number;
1982
2070
  }>;
2071
+ attachBackgroundDispatch(registry: BackgroundDispatchRegistry): () => void;
2072
+ private deliverBackgroundDispatchReport;
1983
2073
  get pendingContextInjectionCount(): number;
1984
2074
  private flushContextInjections;
1985
2075
  get messages(): Message[];