@xenosystem/agent-sdk 0.10.35 → 0.10.37
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/README.md +1 -1
- package/dist/agents/index.cjs +9 -9
- package/dist/agents/index.d.cts +4 -1
- package/dist/agents/index.d.ts +4 -1
- package/dist/agents/index.js +16 -16
- package/dist/agents/metafile-cjs.json +1 -1
- package/dist/agents/metafile-esm.json +1 -1
- package/dist/artifacts/index.cjs +1 -1
- package/dist/artifacts/index.js +1 -1
- package/dist/artifacts/metafile-cjs.json +1 -1
- package/dist/artifacts/metafile-esm.json +1 -1
- package/dist/automation/index.cjs +35 -24
- package/dist/automation/index.d.cts +194 -12
- package/dist/automation/index.d.ts +194 -12
- package/dist/automation/index.js +35 -24
- package/dist/automation/metafile-cjs.json +1 -1
- package/dist/automation/metafile-esm.json +1 -1
- package/dist/control-plane/index.cjs +8 -8
- package/dist/control-plane/index.js +8 -8
- package/dist/control-plane/metafile-cjs.json +1 -1
- package/dist/control-plane/metafile-esm.json +1 -1
- package/dist/coordination/index.cjs +2 -2
- package/dist/coordination/index.js +2 -2
- package/dist/coordination/metafile-cjs.json +1 -1
- package/dist/coordination/metafile-esm.json +1 -1
- package/dist/electron/index.cjs +243 -223
- package/dist/electron/index.d.cts +198 -1
- package/dist/electron/index.d.ts +198 -1
- package/dist/electron/index.js +243 -223
- package/dist/electron/metafile-cjs.json +1 -1
- package/dist/electron/metafile-esm.json +1 -1
- package/dist/hosted/metafile-cjs.json +1 -1
- package/dist/hosted/metafile-esm.json +1 -1
- package/dist/index.cjs +406 -395
- package/dist/index.d.cts +325 -172
- package/dist/index.d.ts +325 -172
- package/dist/index.js +406 -395
- package/dist/intelligence/index.cjs +4 -4
- package/dist/intelligence/index.js +4 -4
- package/dist/intelligence/metafile-cjs.json +1 -1
- package/dist/intelligence/metafile-esm.json +1 -1
- package/dist/mcp/index.cjs +20 -20
- package/dist/mcp/index.d.cts +146 -0
- package/dist/mcp/index.d.ts +146 -0
- package/dist/mcp/index.js +17 -17
- package/dist/mcp/metafile-cjs.json +1 -1
- package/dist/mcp/metafile-esm.json +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/providers/index.cjs +10 -10
- package/dist/providers/index.d.cts +49 -5
- package/dist/providers/index.d.ts +49 -5
- package/dist/providers/index.js +10 -10
- package/dist/providers/metafile-cjs.json +1 -1
- package/dist/providers/metafile-esm.json +1 -1
- package/dist/recipes/metafile-cjs.json +1 -1
- package/dist/recipes/metafile-esm.json +1 -1
- package/dist/research/metafile-cjs.json +1 -1
- package/dist/research/metafile-esm.json +1 -1
- package/dist/session/index.cjs +24 -24
- package/dist/session/index.js +16 -16
- package/dist/session/metafile-cjs.json +1 -1
- package/dist/session/metafile-esm.json +1 -1
- package/dist/sharing/index.cjs +1 -1
- package/dist/sharing/index.js +3 -3
- package/dist/sharing/metafile-cjs.json +1 -1
- package/dist/sharing/metafile-esm.json +1 -1
- package/dist/skills/index.d.cts +6 -0
- package/dist/skills/index.d.ts +6 -0
- package/dist/utils/index.cjs +24 -24
- package/dist/utils/index.d.cts +14 -2
- package/dist/utils/index.d.ts +14 -2
- package/dist/utils/index.js +24 -24
- package/dist/utils/metafile-cjs.json +1 -1
- package/dist/utils/metafile-esm.json +1 -1
- package/ownership/evidence/PROPRIETARY-PTY-1/implementation-record.md +1 -1
- package/ownership/ownership-policy.json +14 -3
- package/package.json +1 -1
|
@@ -166,6 +166,12 @@ interface ToolDefinition {
|
|
|
166
166
|
additionalProperties?: boolean | Record<string, unknown>;
|
|
167
167
|
[keyword: string]: unknown;
|
|
168
168
|
};
|
|
169
|
+
grammar?: ToolInputGrammar;
|
|
170
|
+
}
|
|
171
|
+
interface ToolInputGrammar {
|
|
172
|
+
syntax: "gbnf";
|
|
173
|
+
definition: string;
|
|
174
|
+
inputField: string;
|
|
169
175
|
}
|
|
170
176
|
interface ImageUrlBlock {
|
|
171
177
|
type: "image_url";
|
|
@@ -442,6 +448,14 @@ interface PermissionPromptInfo {
|
|
|
442
448
|
};
|
|
443
449
|
}
|
|
444
450
|
type PermissionPromptFn = (info: PermissionPromptInfo) => Promise<"allow" | "always" | "deny">;
|
|
451
|
+
type MemoryLevel = "global" | "project" | "role" | "session";
|
|
452
|
+
interface MemoryBudget {
|
|
453
|
+
global: number;
|
|
454
|
+
project: number;
|
|
455
|
+
role: number;
|
|
456
|
+
session: number;
|
|
457
|
+
total: number;
|
|
458
|
+
}
|
|
445
459
|
type SessionStatus = "creating" | "active" | "paused" | "completed" | "abandoned" | "archived";
|
|
446
460
|
interface AgentSessionHostBindingV1 {
|
|
447
461
|
schemaVersion: 1;
|
|
@@ -640,6 +654,132 @@ interface PolicyEnforcerConfig {
|
|
|
640
654
|
};
|
|
641
655
|
}
|
|
642
656
|
type AgentSandbox = PolicyEnforcerConfig;
|
|
657
|
+
interface MemoryFile {
|
|
658
|
+
level: MemoryLevel;
|
|
659
|
+
path: string;
|
|
660
|
+
content: string;
|
|
661
|
+
tokenCount: number;
|
|
662
|
+
lastModified?: Date;
|
|
663
|
+
}
|
|
664
|
+
interface ResolvedMemory {
|
|
665
|
+
files: MemoryFile[];
|
|
666
|
+
byLevel: Record<MemoryLevel, string>;
|
|
667
|
+
totalTokens: number;
|
|
668
|
+
truncated: boolean;
|
|
669
|
+
}
|
|
670
|
+
interface ProjectSessionContextEntry {
|
|
671
|
+
sessionId: string;
|
|
672
|
+
model: string;
|
|
673
|
+
lastActivity: string;
|
|
674
|
+
messageCount: number;
|
|
675
|
+
excerpt: string;
|
|
676
|
+
}
|
|
677
|
+
interface ProjectSessionContext {
|
|
678
|
+
entries: ProjectSessionContextEntry[];
|
|
679
|
+
totalTokens: number;
|
|
680
|
+
truncated: boolean;
|
|
681
|
+
content: string;
|
|
682
|
+
}
|
|
683
|
+
interface MemoryManagerOptions {
|
|
684
|
+
cwd: string;
|
|
685
|
+
globalDir?: string;
|
|
686
|
+
role?: string;
|
|
687
|
+
sessionDir?: string;
|
|
688
|
+
scope?: MemoryAccessScope;
|
|
689
|
+
budgets?: Partial<MemoryBudget>;
|
|
690
|
+
projectSessionContext?: {
|
|
691
|
+
limit?: number;
|
|
692
|
+
maxTokens?: number;
|
|
693
|
+
maxCharsPerSession?: number;
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
type MemoryAccessScope = "none" | "session" | "project" | "user";
|
|
697
|
+
declare class MemoryManager {
|
|
698
|
+
private cwd;
|
|
699
|
+
private globalDir;
|
|
700
|
+
private role?;
|
|
701
|
+
private sessionDir?;
|
|
702
|
+
private scope;
|
|
703
|
+
private budgets;
|
|
704
|
+
private projectSessionContextDefaults;
|
|
705
|
+
constructor(options: MemoryManagerOptions);
|
|
706
|
+
get accessScope(): MemoryAccessScope;
|
|
707
|
+
canAccessLevel(level: MemoryLevel): boolean;
|
|
708
|
+
private assertLevelAccess;
|
|
709
|
+
getProjectSessionContextDefaults(): {
|
|
710
|
+
limit: number;
|
|
711
|
+
maxTokens: number;
|
|
712
|
+
maxCharsPerSession: number;
|
|
713
|
+
};
|
|
714
|
+
getPath(level: MemoryLevel): string;
|
|
715
|
+
loadForPrompt(): Promise<ResolvedMemory>;
|
|
716
|
+
loadProjectSessionContext(options?: {
|
|
717
|
+
excludeSessionId?: string;
|
|
718
|
+
limit?: number;
|
|
719
|
+
maxTokens?: number;
|
|
720
|
+
maxCharsPerSession?: number;
|
|
721
|
+
}): Promise<ProjectSessionContext>;
|
|
722
|
+
private filterProjectSessions;
|
|
723
|
+
private normalizePath;
|
|
724
|
+
private extractRecentTranscriptExcerpt;
|
|
725
|
+
private formatProjectSessionEntry;
|
|
726
|
+
add(level: MemoryLevel, content: string, source: "user" | "auto"): Promise<void>;
|
|
727
|
+
set(level: MemoryLevel, content: string): Promise<void>;
|
|
728
|
+
formatForPrompt(memory: ResolvedMemory): string;
|
|
729
|
+
private truncateContent;
|
|
730
|
+
}
|
|
731
|
+
interface AskUserRequest {
|
|
732
|
+
question: string;
|
|
733
|
+
options?: string[];
|
|
734
|
+
context?: string;
|
|
735
|
+
signal?: AbortSignal;
|
|
736
|
+
}
|
|
737
|
+
interface AskUserResponse {
|
|
738
|
+
answer: string;
|
|
739
|
+
selectedOption?: string;
|
|
740
|
+
}
|
|
741
|
+
interface DispatchAgentRequest {
|
|
742
|
+
agent?: string;
|
|
743
|
+
prompt: string;
|
|
744
|
+
timeoutMs?: number;
|
|
745
|
+
signal?: AbortSignal;
|
|
746
|
+
dispatchId?: string;
|
|
747
|
+
}
|
|
748
|
+
interface DispatchAgentTermination {
|
|
749
|
+
status: "completed" | "incomplete" | "suspended" | "interrupted" | "error";
|
|
750
|
+
reason: string;
|
|
751
|
+
message?: string;
|
|
752
|
+
}
|
|
753
|
+
interface DispatchAgentResponse {
|
|
754
|
+
output: string;
|
|
755
|
+
termination?: DispatchAgentTermination;
|
|
756
|
+
tokenUsage?: {
|
|
757
|
+
input: number;
|
|
758
|
+
output: number;
|
|
759
|
+
total: number;
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
interface FileObservation {
|
|
763
|
+
path: string;
|
|
764
|
+
mtimeMs: number;
|
|
765
|
+
size: number;
|
|
766
|
+
source: "read" | "write" | "edit" | "notebook" | "shell";
|
|
767
|
+
requiresRefresh?: boolean;
|
|
768
|
+
reason?: string;
|
|
769
|
+
}
|
|
770
|
+
interface ToolRuntimeContext {
|
|
771
|
+
getCwd(): string;
|
|
772
|
+
setCwd(nextCwd: string): void;
|
|
773
|
+
getOwnerSessionId(): string | undefined;
|
|
774
|
+
getMemoryManager(): MemoryManager | undefined;
|
|
775
|
+
setMemoryManager(memoryManager: MemoryManager | undefined): void;
|
|
776
|
+
noteFileObservation(filePath: string, observation: Omit<FileObservation, "path">): void;
|
|
777
|
+
getFileObservation(filePath: string): FileObservation | undefined;
|
|
778
|
+
invalidateFileObservation(filePath: string, reason: string): void;
|
|
779
|
+
listFileObservations(): FileObservation[];
|
|
780
|
+
askUser?(request: AskUserRequest): Promise<AskUserResponse>;
|
|
781
|
+
dispatchAgent?(request: DispatchAgentRequest): Promise<DispatchAgentResponse>;
|
|
782
|
+
}
|
|
643
783
|
interface ToolRegistryOptions {
|
|
644
784
|
validateInputs?: boolean;
|
|
645
785
|
toolSchemaMode?: "all" | "demand";
|
|
@@ -652,10 +792,14 @@ declare class ToolRegistry {
|
|
|
652
792
|
private validateInputs;
|
|
653
793
|
private readonly toolSchemaMode;
|
|
654
794
|
private readonly activatedDefinitions;
|
|
795
|
+
private memoryRuntime?;
|
|
796
|
+
private memoryBindingScope?;
|
|
655
797
|
constructor(options?: ToolRegistryOptions);
|
|
656
798
|
setValidateInputs(enabled: boolean): this;
|
|
657
799
|
get inputValidationEnabled(): boolean;
|
|
658
800
|
get schemaLoadingMode(): "all" | "demand";
|
|
801
|
+
bindMemoryManager(manager: MemoryManager | undefined): void;
|
|
802
|
+
attachMemoryRuntime(runtime: ToolRuntimeContext, scope?: MemoryManager["accessScope"]): void;
|
|
659
803
|
register(tool: RegisteredTool): void;
|
|
660
804
|
registerAlias(tool: RegisteredTool): void;
|
|
661
805
|
registerAll(tools: Iterable<RegisteredTool>): void;
|
|
@@ -780,6 +924,44 @@ declare class PermissionEngine {
|
|
|
780
924
|
private normalizeCommandText;
|
|
781
925
|
private resolveTargetPath;
|
|
782
926
|
}
|
|
927
|
+
type HookEventName = "SessionStart" | "UserPromptSubmit" | "PermissionRequest" | "PreToolUse" | "PostToolUse" | "PreCompact" | "PostCompact" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop";
|
|
928
|
+
interface BaseHookDefinition {
|
|
929
|
+
name?: string;
|
|
930
|
+
events?: HookEventName[];
|
|
931
|
+
timeoutMs?: number;
|
|
932
|
+
maxOutputBytes?: number;
|
|
933
|
+
failClosed?: boolean;
|
|
934
|
+
async?: boolean;
|
|
935
|
+
}
|
|
936
|
+
interface CommandHookDefinition extends BaseHookDefinition {
|
|
937
|
+
type: "command";
|
|
938
|
+
command: string;
|
|
939
|
+
args?: string[];
|
|
940
|
+
cwd?: string;
|
|
941
|
+
shell?: boolean;
|
|
942
|
+
env?: Record<string, string>;
|
|
943
|
+
}
|
|
944
|
+
interface HttpHookDefinition extends BaseHookDefinition {
|
|
945
|
+
type: "http";
|
|
946
|
+
url: string;
|
|
947
|
+
method?: "POST";
|
|
948
|
+
headers?: Record<string, string>;
|
|
949
|
+
}
|
|
950
|
+
interface PromptHookDefinition extends BaseHookDefinition {
|
|
951
|
+
type: "prompt";
|
|
952
|
+
prompt: string;
|
|
953
|
+
}
|
|
954
|
+
interface AgentHookDefinition extends BaseHookDefinition {
|
|
955
|
+
type: "agent";
|
|
956
|
+
prompt: string;
|
|
957
|
+
agent?: string;
|
|
958
|
+
model?: string;
|
|
959
|
+
}
|
|
960
|
+
type HookDefinition = CommandHookDefinition | HttpHookDefinition | PromptHookDefinition | AgentHookDefinition;
|
|
961
|
+
interface HookConfig {
|
|
962
|
+
hooks?: HookDefinition[];
|
|
963
|
+
events?: Partial<Record<HookEventName, HookDefinition[]>>;
|
|
964
|
+
}
|
|
783
965
|
type ToolFailureCategory = "schema" | "missing_path" | "permission_denied" | "transport" | "timeout" | "tool_failure";
|
|
784
966
|
interface ToolFailureGuardTrip {
|
|
785
967
|
category: ToolFailureCategory;
|
|
@@ -842,6 +1024,7 @@ type XenoChatMessage = {
|
|
|
842
1024
|
};
|
|
843
1025
|
interface StreamResult {
|
|
844
1026
|
content: ContentBlock[];
|
|
1027
|
+
reasoningContent?: string;
|
|
845
1028
|
stopReason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence";
|
|
846
1029
|
inputTokens: number;
|
|
847
1030
|
outputTokens: number;
|
|
@@ -900,8 +1083,10 @@ interface LlmClientDeps {
|
|
|
900
1083
|
reportFailure(diagnostics: ApiRequestFailureDiagnostics): Promise<void>;
|
|
901
1084
|
}
|
|
902
1085
|
declare class LlmClient {
|
|
903
|
-
private
|
|
1086
|
+
private deps;
|
|
904
1087
|
constructor(deps: LlmClientDeps);
|
|
1088
|
+
configureAuthorization(options: Pick<LlmClientDeps, "apiKey" | "authorizeRequest">): void;
|
|
1089
|
+
private localGrammarProbe?;
|
|
905
1090
|
readonly id = "xeno-llm-client";
|
|
906
1091
|
complete(model: string, messages: ApiMessage[], tools: ToolDefinition[], onText?: (text: string) => void, signal?: AbortSignal): Promise<StreamResult>;
|
|
907
1092
|
completeLocal(model: string, messages: ApiMessage[], tools: ToolDefinition[], onText?: (text: string) => void, signal?: AbortSignal): Promise<StreamResult>;
|
|
@@ -1012,6 +1197,9 @@ interface LLMProviderRequestContext {
|
|
|
1012
1197
|
systemPrompt: string;
|
|
1013
1198
|
attemptId?: string;
|
|
1014
1199
|
quotaRemainingTokens?: number;
|
|
1200
|
+
toolChoice?: "auto" | "none" | "required" | {
|
|
1201
|
+
name: string;
|
|
1202
|
+
};
|
|
1015
1203
|
onEvent?: (event: ProviderStreamEvent) => void | Promise<void>;
|
|
1016
1204
|
}
|
|
1017
1205
|
interface LLMProviderCapabilities {
|
|
@@ -1027,6 +1215,8 @@ interface LLMProviderCapabilities {
|
|
|
1027
1215
|
readonly cancellation?: boolean;
|
|
1028
1216
|
readonly retryAfter?: boolean;
|
|
1029
1217
|
readonly promptCaching?: boolean;
|
|
1218
|
+
readonly customToolGrammarsGbnf?: boolean;
|
|
1219
|
+
readonly customToolGrammarsGbnfStreaming?: boolean;
|
|
1030
1220
|
readonly [capability: string]: boolean | undefined;
|
|
1031
1221
|
}
|
|
1032
1222
|
interface LLMProvider {
|
|
@@ -1558,6 +1748,7 @@ interface AgentLoopConfig {
|
|
|
1558
1748
|
onIteration?: (iteration: number, totalTokens: number) => void;
|
|
1559
1749
|
modelWorkAccounting?: ModelWorkAccounting;
|
|
1560
1750
|
runAuthority?: RunAuthority;
|
|
1751
|
+
hooks?: HookConfig;
|
|
1561
1752
|
onError?: (error: Error, context: string) => void;
|
|
1562
1753
|
onTranscriptError?: (error: Error, context: string) => void;
|
|
1563
1754
|
onModeSwitchRequest?: (request: ModeSwitchRequest) => Promise<boolean>;
|
|
@@ -1682,6 +1873,7 @@ declare class AgentLoop {
|
|
|
1682
1873
|
private readonly promptSections;
|
|
1683
1874
|
private readonly completionGuards;
|
|
1684
1875
|
private readonly toolFailureGuard;
|
|
1876
|
+
private readonly preToolUseGate;
|
|
1685
1877
|
private turnToolCalls;
|
|
1686
1878
|
private turnToolFailures;
|
|
1687
1879
|
private turnFailuresByTool;
|
|
@@ -1705,6 +1897,11 @@ declare class AgentLoop {
|
|
|
1705
1897
|
modelWorkAccounting?: ModelWorkAccounting;
|
|
1706
1898
|
runAuthority?: RunAuthority;
|
|
1707
1899
|
}): void;
|
|
1900
|
+
configureRequestAuthorization(options: {
|
|
1901
|
+
apiKey?: string;
|
|
1902
|
+
authorizeRequest?: AgentLoopConfig["authorizeRequest"];
|
|
1903
|
+
}): void;
|
|
1904
|
+
createChildRequestAuthorizer(): NonNullable<AgentLoopConfig["authorizeRequest"]>;
|
|
1708
1905
|
get lastTraceId(): string | null;
|
|
1709
1906
|
get lastRunTermination(): AgentRunTermination | null;
|
|
1710
1907
|
get queryState(): QueryState;
|
package/dist/electron/index.d.ts
CHANGED
|
@@ -166,6 +166,12 @@ interface ToolDefinition {
|
|
|
166
166
|
additionalProperties?: boolean | Record<string, unknown>;
|
|
167
167
|
[keyword: string]: unknown;
|
|
168
168
|
};
|
|
169
|
+
grammar?: ToolInputGrammar;
|
|
170
|
+
}
|
|
171
|
+
interface ToolInputGrammar {
|
|
172
|
+
syntax: "gbnf";
|
|
173
|
+
definition: string;
|
|
174
|
+
inputField: string;
|
|
169
175
|
}
|
|
170
176
|
interface ImageUrlBlock {
|
|
171
177
|
type: "image_url";
|
|
@@ -442,6 +448,14 @@ interface PermissionPromptInfo {
|
|
|
442
448
|
};
|
|
443
449
|
}
|
|
444
450
|
type PermissionPromptFn = (info: PermissionPromptInfo) => Promise<"allow" | "always" | "deny">;
|
|
451
|
+
type MemoryLevel = "global" | "project" | "role" | "session";
|
|
452
|
+
interface MemoryBudget {
|
|
453
|
+
global: number;
|
|
454
|
+
project: number;
|
|
455
|
+
role: number;
|
|
456
|
+
session: number;
|
|
457
|
+
total: number;
|
|
458
|
+
}
|
|
445
459
|
type SessionStatus = "creating" | "active" | "paused" | "completed" | "abandoned" | "archived";
|
|
446
460
|
interface AgentSessionHostBindingV1 {
|
|
447
461
|
schemaVersion: 1;
|
|
@@ -640,6 +654,132 @@ interface PolicyEnforcerConfig {
|
|
|
640
654
|
};
|
|
641
655
|
}
|
|
642
656
|
type AgentSandbox = PolicyEnforcerConfig;
|
|
657
|
+
interface MemoryFile {
|
|
658
|
+
level: MemoryLevel;
|
|
659
|
+
path: string;
|
|
660
|
+
content: string;
|
|
661
|
+
tokenCount: number;
|
|
662
|
+
lastModified?: Date;
|
|
663
|
+
}
|
|
664
|
+
interface ResolvedMemory {
|
|
665
|
+
files: MemoryFile[];
|
|
666
|
+
byLevel: Record<MemoryLevel, string>;
|
|
667
|
+
totalTokens: number;
|
|
668
|
+
truncated: boolean;
|
|
669
|
+
}
|
|
670
|
+
interface ProjectSessionContextEntry {
|
|
671
|
+
sessionId: string;
|
|
672
|
+
model: string;
|
|
673
|
+
lastActivity: string;
|
|
674
|
+
messageCount: number;
|
|
675
|
+
excerpt: string;
|
|
676
|
+
}
|
|
677
|
+
interface ProjectSessionContext {
|
|
678
|
+
entries: ProjectSessionContextEntry[];
|
|
679
|
+
totalTokens: number;
|
|
680
|
+
truncated: boolean;
|
|
681
|
+
content: string;
|
|
682
|
+
}
|
|
683
|
+
interface MemoryManagerOptions {
|
|
684
|
+
cwd: string;
|
|
685
|
+
globalDir?: string;
|
|
686
|
+
role?: string;
|
|
687
|
+
sessionDir?: string;
|
|
688
|
+
scope?: MemoryAccessScope;
|
|
689
|
+
budgets?: Partial<MemoryBudget>;
|
|
690
|
+
projectSessionContext?: {
|
|
691
|
+
limit?: number;
|
|
692
|
+
maxTokens?: number;
|
|
693
|
+
maxCharsPerSession?: number;
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
type MemoryAccessScope = "none" | "session" | "project" | "user";
|
|
697
|
+
declare class MemoryManager {
|
|
698
|
+
private cwd;
|
|
699
|
+
private globalDir;
|
|
700
|
+
private role?;
|
|
701
|
+
private sessionDir?;
|
|
702
|
+
private scope;
|
|
703
|
+
private budgets;
|
|
704
|
+
private projectSessionContextDefaults;
|
|
705
|
+
constructor(options: MemoryManagerOptions);
|
|
706
|
+
get accessScope(): MemoryAccessScope;
|
|
707
|
+
canAccessLevel(level: MemoryLevel): boolean;
|
|
708
|
+
private assertLevelAccess;
|
|
709
|
+
getProjectSessionContextDefaults(): {
|
|
710
|
+
limit: number;
|
|
711
|
+
maxTokens: number;
|
|
712
|
+
maxCharsPerSession: number;
|
|
713
|
+
};
|
|
714
|
+
getPath(level: MemoryLevel): string;
|
|
715
|
+
loadForPrompt(): Promise<ResolvedMemory>;
|
|
716
|
+
loadProjectSessionContext(options?: {
|
|
717
|
+
excludeSessionId?: string;
|
|
718
|
+
limit?: number;
|
|
719
|
+
maxTokens?: number;
|
|
720
|
+
maxCharsPerSession?: number;
|
|
721
|
+
}): Promise<ProjectSessionContext>;
|
|
722
|
+
private filterProjectSessions;
|
|
723
|
+
private normalizePath;
|
|
724
|
+
private extractRecentTranscriptExcerpt;
|
|
725
|
+
private formatProjectSessionEntry;
|
|
726
|
+
add(level: MemoryLevel, content: string, source: "user" | "auto"): Promise<void>;
|
|
727
|
+
set(level: MemoryLevel, content: string): Promise<void>;
|
|
728
|
+
formatForPrompt(memory: ResolvedMemory): string;
|
|
729
|
+
private truncateContent;
|
|
730
|
+
}
|
|
731
|
+
interface AskUserRequest {
|
|
732
|
+
question: string;
|
|
733
|
+
options?: string[];
|
|
734
|
+
context?: string;
|
|
735
|
+
signal?: AbortSignal;
|
|
736
|
+
}
|
|
737
|
+
interface AskUserResponse {
|
|
738
|
+
answer: string;
|
|
739
|
+
selectedOption?: string;
|
|
740
|
+
}
|
|
741
|
+
interface DispatchAgentRequest {
|
|
742
|
+
agent?: string;
|
|
743
|
+
prompt: string;
|
|
744
|
+
timeoutMs?: number;
|
|
745
|
+
signal?: AbortSignal;
|
|
746
|
+
dispatchId?: string;
|
|
747
|
+
}
|
|
748
|
+
interface DispatchAgentTermination {
|
|
749
|
+
status: "completed" | "incomplete" | "suspended" | "interrupted" | "error";
|
|
750
|
+
reason: string;
|
|
751
|
+
message?: string;
|
|
752
|
+
}
|
|
753
|
+
interface DispatchAgentResponse {
|
|
754
|
+
output: string;
|
|
755
|
+
termination?: DispatchAgentTermination;
|
|
756
|
+
tokenUsage?: {
|
|
757
|
+
input: number;
|
|
758
|
+
output: number;
|
|
759
|
+
total: number;
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
interface FileObservation {
|
|
763
|
+
path: string;
|
|
764
|
+
mtimeMs: number;
|
|
765
|
+
size: number;
|
|
766
|
+
source: "read" | "write" | "edit" | "notebook" | "shell";
|
|
767
|
+
requiresRefresh?: boolean;
|
|
768
|
+
reason?: string;
|
|
769
|
+
}
|
|
770
|
+
interface ToolRuntimeContext {
|
|
771
|
+
getCwd(): string;
|
|
772
|
+
setCwd(nextCwd: string): void;
|
|
773
|
+
getOwnerSessionId(): string | undefined;
|
|
774
|
+
getMemoryManager(): MemoryManager | undefined;
|
|
775
|
+
setMemoryManager(memoryManager: MemoryManager | undefined): void;
|
|
776
|
+
noteFileObservation(filePath: string, observation: Omit<FileObservation, "path">): void;
|
|
777
|
+
getFileObservation(filePath: string): FileObservation | undefined;
|
|
778
|
+
invalidateFileObservation(filePath: string, reason: string): void;
|
|
779
|
+
listFileObservations(): FileObservation[];
|
|
780
|
+
askUser?(request: AskUserRequest): Promise<AskUserResponse>;
|
|
781
|
+
dispatchAgent?(request: DispatchAgentRequest): Promise<DispatchAgentResponse>;
|
|
782
|
+
}
|
|
643
783
|
interface ToolRegistryOptions {
|
|
644
784
|
validateInputs?: boolean;
|
|
645
785
|
toolSchemaMode?: "all" | "demand";
|
|
@@ -652,10 +792,14 @@ declare class ToolRegistry {
|
|
|
652
792
|
private validateInputs;
|
|
653
793
|
private readonly toolSchemaMode;
|
|
654
794
|
private readonly activatedDefinitions;
|
|
795
|
+
private memoryRuntime?;
|
|
796
|
+
private memoryBindingScope?;
|
|
655
797
|
constructor(options?: ToolRegistryOptions);
|
|
656
798
|
setValidateInputs(enabled: boolean): this;
|
|
657
799
|
get inputValidationEnabled(): boolean;
|
|
658
800
|
get schemaLoadingMode(): "all" | "demand";
|
|
801
|
+
bindMemoryManager(manager: MemoryManager | undefined): void;
|
|
802
|
+
attachMemoryRuntime(runtime: ToolRuntimeContext, scope?: MemoryManager["accessScope"]): void;
|
|
659
803
|
register(tool: RegisteredTool): void;
|
|
660
804
|
registerAlias(tool: RegisteredTool): void;
|
|
661
805
|
registerAll(tools: Iterable<RegisteredTool>): void;
|
|
@@ -780,6 +924,44 @@ declare class PermissionEngine {
|
|
|
780
924
|
private normalizeCommandText;
|
|
781
925
|
private resolveTargetPath;
|
|
782
926
|
}
|
|
927
|
+
type HookEventName = "SessionStart" | "UserPromptSubmit" | "PermissionRequest" | "PreToolUse" | "PostToolUse" | "PreCompact" | "PostCompact" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop";
|
|
928
|
+
interface BaseHookDefinition {
|
|
929
|
+
name?: string;
|
|
930
|
+
events?: HookEventName[];
|
|
931
|
+
timeoutMs?: number;
|
|
932
|
+
maxOutputBytes?: number;
|
|
933
|
+
failClosed?: boolean;
|
|
934
|
+
async?: boolean;
|
|
935
|
+
}
|
|
936
|
+
interface CommandHookDefinition extends BaseHookDefinition {
|
|
937
|
+
type: "command";
|
|
938
|
+
command: string;
|
|
939
|
+
args?: string[];
|
|
940
|
+
cwd?: string;
|
|
941
|
+
shell?: boolean;
|
|
942
|
+
env?: Record<string, string>;
|
|
943
|
+
}
|
|
944
|
+
interface HttpHookDefinition extends BaseHookDefinition {
|
|
945
|
+
type: "http";
|
|
946
|
+
url: string;
|
|
947
|
+
method?: "POST";
|
|
948
|
+
headers?: Record<string, string>;
|
|
949
|
+
}
|
|
950
|
+
interface PromptHookDefinition extends BaseHookDefinition {
|
|
951
|
+
type: "prompt";
|
|
952
|
+
prompt: string;
|
|
953
|
+
}
|
|
954
|
+
interface AgentHookDefinition extends BaseHookDefinition {
|
|
955
|
+
type: "agent";
|
|
956
|
+
prompt: string;
|
|
957
|
+
agent?: string;
|
|
958
|
+
model?: string;
|
|
959
|
+
}
|
|
960
|
+
type HookDefinition = CommandHookDefinition | HttpHookDefinition | PromptHookDefinition | AgentHookDefinition;
|
|
961
|
+
interface HookConfig {
|
|
962
|
+
hooks?: HookDefinition[];
|
|
963
|
+
events?: Partial<Record<HookEventName, HookDefinition[]>>;
|
|
964
|
+
}
|
|
783
965
|
type ToolFailureCategory = "schema" | "missing_path" | "permission_denied" | "transport" | "timeout" | "tool_failure";
|
|
784
966
|
interface ToolFailureGuardTrip {
|
|
785
967
|
category: ToolFailureCategory;
|
|
@@ -842,6 +1024,7 @@ type XenoChatMessage = {
|
|
|
842
1024
|
};
|
|
843
1025
|
interface StreamResult {
|
|
844
1026
|
content: ContentBlock[];
|
|
1027
|
+
reasoningContent?: string;
|
|
845
1028
|
stopReason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence";
|
|
846
1029
|
inputTokens: number;
|
|
847
1030
|
outputTokens: number;
|
|
@@ -900,8 +1083,10 @@ interface LlmClientDeps {
|
|
|
900
1083
|
reportFailure(diagnostics: ApiRequestFailureDiagnostics): Promise<void>;
|
|
901
1084
|
}
|
|
902
1085
|
declare class LlmClient {
|
|
903
|
-
private
|
|
1086
|
+
private deps;
|
|
904
1087
|
constructor(deps: LlmClientDeps);
|
|
1088
|
+
configureAuthorization(options: Pick<LlmClientDeps, "apiKey" | "authorizeRequest">): void;
|
|
1089
|
+
private localGrammarProbe?;
|
|
905
1090
|
readonly id = "xeno-llm-client";
|
|
906
1091
|
complete(model: string, messages: ApiMessage[], tools: ToolDefinition[], onText?: (text: string) => void, signal?: AbortSignal): Promise<StreamResult>;
|
|
907
1092
|
completeLocal(model: string, messages: ApiMessage[], tools: ToolDefinition[], onText?: (text: string) => void, signal?: AbortSignal): Promise<StreamResult>;
|
|
@@ -1012,6 +1197,9 @@ interface LLMProviderRequestContext {
|
|
|
1012
1197
|
systemPrompt: string;
|
|
1013
1198
|
attemptId?: string;
|
|
1014
1199
|
quotaRemainingTokens?: number;
|
|
1200
|
+
toolChoice?: "auto" | "none" | "required" | {
|
|
1201
|
+
name: string;
|
|
1202
|
+
};
|
|
1015
1203
|
onEvent?: (event: ProviderStreamEvent) => void | Promise<void>;
|
|
1016
1204
|
}
|
|
1017
1205
|
interface LLMProviderCapabilities {
|
|
@@ -1027,6 +1215,8 @@ interface LLMProviderCapabilities {
|
|
|
1027
1215
|
readonly cancellation?: boolean;
|
|
1028
1216
|
readonly retryAfter?: boolean;
|
|
1029
1217
|
readonly promptCaching?: boolean;
|
|
1218
|
+
readonly customToolGrammarsGbnf?: boolean;
|
|
1219
|
+
readonly customToolGrammarsGbnfStreaming?: boolean;
|
|
1030
1220
|
readonly [capability: string]: boolean | undefined;
|
|
1031
1221
|
}
|
|
1032
1222
|
interface LLMProvider {
|
|
@@ -1558,6 +1748,7 @@ interface AgentLoopConfig {
|
|
|
1558
1748
|
onIteration?: (iteration: number, totalTokens: number) => void;
|
|
1559
1749
|
modelWorkAccounting?: ModelWorkAccounting;
|
|
1560
1750
|
runAuthority?: RunAuthority;
|
|
1751
|
+
hooks?: HookConfig;
|
|
1561
1752
|
onError?: (error: Error, context: string) => void;
|
|
1562
1753
|
onTranscriptError?: (error: Error, context: string) => void;
|
|
1563
1754
|
onModeSwitchRequest?: (request: ModeSwitchRequest) => Promise<boolean>;
|
|
@@ -1682,6 +1873,7 @@ declare class AgentLoop {
|
|
|
1682
1873
|
private readonly promptSections;
|
|
1683
1874
|
private readonly completionGuards;
|
|
1684
1875
|
private readonly toolFailureGuard;
|
|
1876
|
+
private readonly preToolUseGate;
|
|
1685
1877
|
private turnToolCalls;
|
|
1686
1878
|
private turnToolFailures;
|
|
1687
1879
|
private turnFailuresByTool;
|
|
@@ -1705,6 +1897,11 @@ declare class AgentLoop {
|
|
|
1705
1897
|
modelWorkAccounting?: ModelWorkAccounting;
|
|
1706
1898
|
runAuthority?: RunAuthority;
|
|
1707
1899
|
}): void;
|
|
1900
|
+
configureRequestAuthorization(options: {
|
|
1901
|
+
apiKey?: string;
|
|
1902
|
+
authorizeRequest?: AgentLoopConfig["authorizeRequest"];
|
|
1903
|
+
}): void;
|
|
1904
|
+
createChildRequestAuthorizer(): NonNullable<AgentLoopConfig["authorizeRequest"]>;
|
|
1708
1905
|
get lastTraceId(): string | null;
|
|
1709
1906
|
get lastRunTermination(): AgentRunTermination | null;
|
|
1710
1907
|
get queryState(): QueryState;
|