@crewx/sdk 0.9.0-rc.160 → 0.9.0-rc.162
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/agent-interceptor/chain.d.ts +25 -0
- package/dist/agent-interceptor/index.d.ts +6 -0
- package/dist/agent-interceptor/model-runner.d.ts +19 -0
- package/dist/agent-interceptor/program-runner.d.ts +13 -0
- package/dist/agent-interceptor/protocol.d.ts +68 -0
- package/dist/agent-interceptor/run-stop.d.ts +3 -0
- package/dist/agent-interceptor/schema.d.ts +267 -0
- package/dist/agent-interceptor/types.d.ts +88 -0
- package/dist/app/app.d.ts +10 -1
- package/dist/app/index.d.ts +2 -0
- package/dist/app/index.js +10 -10
- package/dist/app/schedule-contract.d.ts +59 -0
- package/dist/esm/app/index.js +10 -10
- package/dist/esm/index.js +237 -229
- package/dist/esm/plugins/index.js +86 -81
- package/dist/esm/publish/index.js +2 -2
- package/dist/esm/repository/index.js +98 -93
- package/dist/esm/skills/index.js +2 -2
- package/dist/events/types.d.ts +12 -0
- package/dist/facade/Crewx.d.ts +9 -0
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.js +4 -4
- package/dist/index.d.ts +14 -3
- package/dist/index.js +306 -298
- package/dist/mcp-app/app-icon-read.d.ts +7 -0
- package/dist/mcp-app/app-schedule.d.ts +85 -0
- package/dist/mcp-app/dev-checks.d.ts +2 -0
- package/dist/mcp-app/discovery.d.ts +3 -0
- package/dist/mcp-app/index.d.ts +5 -1
- package/dist/mcp-app/skill-backend.d.ts +5 -2
- package/dist/mcp-app/workspace-snapshot.d.ts +3 -0
- package/dist/plugins/index.js +83 -78
- package/dist/provider/bridge.d.ts +5 -1
- package/dist/provider/cli/adapter.types.d.ts +9 -0
- package/dist/provider-account/accounts.d.ts +15 -0
- package/dist/provider-account/index.d.ts +5 -0
- package/dist/provider-account/registry.d.ts +30 -0
- package/dist/provider-account/types.d.ts +40 -0
- package/dist/publish/errors.d.ts +1 -1
- package/dist/publish/index.d.ts +5 -0
- package/dist/publish/index.js +2 -2
- package/dist/repository/index.js +99 -94
- package/dist/repository/task.repository.d.ts +7 -0
- package/dist/repository/thread.repository.d.ts +1 -0
- package/dist/skills/index.js +2 -2
- package/dist/types/index.d.ts +33 -0
- package/dist/types/task-log.types.d.ts +3 -1
- package/dist/ui-instance/types.d.ts +8 -0
- package/dist/ui-plugin/app-icon.d.ts +50 -0
- package/dist/ui-plugin/index.d.ts +2 -0
- package/dist/ui-plugin/types.d.ts +2 -1
- package/dist/utils/id.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ModelProviderFactory } from './model-runner';
|
|
2
|
+
import { type AgentInterceptorItem, type InterceptorLaneRun, type InterceptorPhase } from './types';
|
|
3
|
+
export interface InterceptorRunContext {
|
|
4
|
+
cwd: string;
|
|
5
|
+
agentId: string;
|
|
6
|
+
traceId: string;
|
|
7
|
+
threadId?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
onSpawn?: (pid: number) => void;
|
|
11
|
+
onExit?: () => void;
|
|
12
|
+
providerFactory?: ModelProviderFactory;
|
|
13
|
+
}
|
|
14
|
+
export declare class AgentInterceptorChain {
|
|
15
|
+
readonly items: readonly AgentInterceptorItem[];
|
|
16
|
+
private constructor();
|
|
17
|
+
static fromAgent(agent: {
|
|
18
|
+
id: string;
|
|
19
|
+
interceptors?: unknown;
|
|
20
|
+
}): AgentInterceptorChain | undefined;
|
|
21
|
+
hasPhase(phase: InterceptorPhase): boolean;
|
|
22
|
+
get responseIntercepted(): boolean;
|
|
23
|
+
run(phase: InterceptorPhase, text: string, ctx: InterceptorRunContext): Promise<InterceptorLaneRun>;
|
|
24
|
+
private invoke;
|
|
25
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AgentInterceptorChain, type InterceptorRunContext } from './chain';
|
|
2
|
+
export { AgentInterceptorConfigError, AgentInterceptorItemSchema, AgentInterceptorChainSchema, AGENT_INTERCEPTOR_SCHEMA_VERSION, parseAgentInterceptorItems, } from './schema';
|
|
3
|
+
export { runProgramInterceptor, buildProgramInterceptorEnv } from './program-runner';
|
|
4
|
+
export { runModelInterceptor, buildModelInterceptorSystemPrompt, type ModelProviderFactory } from './model-runner';
|
|
5
|
+
export { RPC_CODE } from './protocol';
|
|
6
|
+
export { INTERCEPTOR_BLOCKED, INTERCEPTOR_CONFIG_INVALID, INTERCEPTOR_FAILED, INTERCEPTOR_STOPPED, type AgentInterceptorItem, type InterceptorInvocation, type InterceptorLaneRun, type InterceptorMode, type InterceptorOutcome, type InterceptorPhase, type InterceptorSeverity, type InterceptorStepLog, type InterceptorType, type InterceptorUsage, type InterceptorVerdict, } from './types';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ProviderRuntime } from '../provider/bridge';
|
|
2
|
+
import type { InterceptorInvocation, InterceptorType } from './types';
|
|
3
|
+
export type ModelProviderFactory = (providerStr: string) => ProviderRuntime;
|
|
4
|
+
export interface ModelInterceptorInvocation {
|
|
5
|
+
providerStr: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
instruction: string;
|
|
8
|
+
type: InterceptorType;
|
|
9
|
+
role: string;
|
|
10
|
+
text: string;
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
cwd: string;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
onSpawn?: (pid: number) => void;
|
|
15
|
+
onExit?: () => void;
|
|
16
|
+
providerFactory?: ModelProviderFactory;
|
|
17
|
+
}
|
|
18
|
+
export declare function buildModelInterceptorSystemPrompt(type: InterceptorType, instruction: string): string;
|
|
19
|
+
export declare function runModelInterceptor(input: ModelInterceptorInvocation): Promise<InterceptorInvocation>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type InterceptorInvokeRequest } from './protocol';
|
|
2
|
+
import type { InterceptorInvocation } from './types';
|
|
3
|
+
export declare function buildProgramInterceptorEnv(source?: NodeJS.ProcessEnv): Record<string, string>;
|
|
4
|
+
export interface ProgramInterceptorInvocation {
|
|
5
|
+
command: readonly string[];
|
|
6
|
+
cwd: string;
|
|
7
|
+
request: InterceptorInvokeRequest;
|
|
8
|
+
timeoutMs: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
onSpawn?: (pid: number) => void;
|
|
11
|
+
onExit?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function runProgramInterceptor(input: ProgramInterceptorInvocation): Promise<InterceptorInvocation>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { InterceptorMessage, InterceptorVerdict } from './types';
|
|
2
|
+
export declare const INTERCEPTOR_RPC_METHOD = "interceptor/invoke";
|
|
3
|
+
export declare const INTERCEPTOR_RPC_EVENT = "crewx/agent.run";
|
|
4
|
+
export declare const INTERCEPTOR_RPC_ID = 1;
|
|
5
|
+
export declare const INTERCEPTOR_STDOUT_MAX_BYTES: number;
|
|
6
|
+
export declare const RPC_CODE: {
|
|
7
|
+
readonly TIMEOUT: -32000;
|
|
8
|
+
readonly EXIT_FAILURE: -32001;
|
|
9
|
+
readonly MALFORMED_OUTPUT: -32002;
|
|
10
|
+
readonly OUTPUT_TOO_LARGE: -32003;
|
|
11
|
+
readonly SPAWN_FAILED: -32004;
|
|
12
|
+
readonly ABORTED: -32005;
|
|
13
|
+
readonly PAYLOAD_INVALID: -32006;
|
|
14
|
+
readonly PROVIDER_FAILED: -32007;
|
|
15
|
+
};
|
|
16
|
+
export interface InterceptorInvokeRequest {
|
|
17
|
+
jsonrpc: '2.0';
|
|
18
|
+
id: number;
|
|
19
|
+
method: typeof INTERCEPTOR_RPC_METHOD;
|
|
20
|
+
params: {
|
|
21
|
+
name: string;
|
|
22
|
+
event: typeof INTERCEPTOR_RPC_EVENT;
|
|
23
|
+
phase: 'request' | 'response';
|
|
24
|
+
payload: {
|
|
25
|
+
messages: InterceptorMessage[];
|
|
26
|
+
model: string | null;
|
|
27
|
+
};
|
|
28
|
+
config: Record<string, unknown>;
|
|
29
|
+
timeoutMs: number;
|
|
30
|
+
context: {
|
|
31
|
+
sessionId: string;
|
|
32
|
+
traceId: string;
|
|
33
|
+
agentId: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare function buildInvokeRequest(input: {
|
|
38
|
+
name: string;
|
|
39
|
+
phase: 'request' | 'response';
|
|
40
|
+
messages: InterceptorMessage[];
|
|
41
|
+
model: string | null;
|
|
42
|
+
config: Record<string, unknown>;
|
|
43
|
+
timeoutMs: number;
|
|
44
|
+
sessionId: string;
|
|
45
|
+
traceId: string;
|
|
46
|
+
agentId: string;
|
|
47
|
+
}): InterceptorInvokeRequest;
|
|
48
|
+
export type RpcFailure = {
|
|
49
|
+
ok: false;
|
|
50
|
+
code: number;
|
|
51
|
+
message: string;
|
|
52
|
+
};
|
|
53
|
+
export type RpcParse = {
|
|
54
|
+
ok: true;
|
|
55
|
+
result: unknown;
|
|
56
|
+
} | RpcFailure;
|
|
57
|
+
export declare function parseSingleRpcResponse(stdout: string, id: number): RpcParse;
|
|
58
|
+
export type MutationInterpretation = {
|
|
59
|
+
ok: true;
|
|
60
|
+
modified: boolean;
|
|
61
|
+
messages: InterceptorMessage[];
|
|
62
|
+
} | RpcFailure;
|
|
63
|
+
export declare function interpretMutationResult(result: unknown, input: InterceptorMessage[]): MutationInterpretation;
|
|
64
|
+
export type ValidationInterpretation = {
|
|
65
|
+
ok: true;
|
|
66
|
+
verdict: InterceptorVerdict;
|
|
67
|
+
} | RpcFailure;
|
|
68
|
+
export declare function interpretValidationResult(result: unknown): ValidationInterpretation;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function registerInterceptorRunStop(taskId: string, controller: AbortController): void;
|
|
2
|
+
export declare function releaseInterceptorRunStop(taskId: string, controller: AbortController): void;
|
|
3
|
+
export declare function requestInterceptorRunStop(taskId: string): boolean;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type AgentInterceptorItem } from './types';
|
|
3
|
+
export declare const AGENT_INTERCEPTOR_SCHEMA_VERSION = 1;
|
|
4
|
+
export declare const AGENT_INTERCEPTOR_DEFAULT_TIMEOUT_MS = 10000;
|
|
5
|
+
export declare const AGENT_INTERCEPTOR_MAX_TIMEOUT_MS = 120000;
|
|
6
|
+
export declare const AgentInterceptorItemSchema: z.ZodEffects<z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
type: z.ZodEnum<["mutation", "validation"]>;
|
|
9
|
+
phase: z.ZodEnum<["request", "response"]>;
|
|
10
|
+
mode: z.ZodDefault<z.ZodEnum<["active", "audit"]>>;
|
|
11
|
+
failOpen: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
priorityHint: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
16
|
+
command: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
provider: z.ZodString;
|
|
19
|
+
model: z.ZodOptional<z.ZodString>;
|
|
20
|
+
instruction: z.ZodString;
|
|
21
|
+
}, "strict", z.ZodTypeAny, {
|
|
22
|
+
provider: string;
|
|
23
|
+
instruction: string;
|
|
24
|
+
model?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
provider: string;
|
|
27
|
+
instruction: string;
|
|
28
|
+
model?: string | undefined;
|
|
29
|
+
}>>;
|
|
30
|
+
}, "strict", z.ZodTypeAny, {
|
|
31
|
+
name: string;
|
|
32
|
+
mode: "active" | "audit";
|
|
33
|
+
type: "mutation" | "validation";
|
|
34
|
+
config: Record<string, unknown>;
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
timeoutMs: number;
|
|
37
|
+
phase: "request" | "response";
|
|
38
|
+
failOpen: boolean;
|
|
39
|
+
priorityHint: number;
|
|
40
|
+
model?: {
|
|
41
|
+
provider: string;
|
|
42
|
+
instruction: string;
|
|
43
|
+
model?: string | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
command?: string[] | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
name: string;
|
|
48
|
+
type: "mutation" | "validation";
|
|
49
|
+
phase: "request" | "response";
|
|
50
|
+
mode?: "active" | "audit" | undefined;
|
|
51
|
+
model?: {
|
|
52
|
+
provider: string;
|
|
53
|
+
instruction: string;
|
|
54
|
+
model?: string | undefined;
|
|
55
|
+
} | undefined;
|
|
56
|
+
command?: string[] | undefined;
|
|
57
|
+
config?: Record<string, unknown> | undefined;
|
|
58
|
+
enabled?: boolean | undefined;
|
|
59
|
+
timeoutMs?: number | undefined;
|
|
60
|
+
failOpen?: boolean | undefined;
|
|
61
|
+
priorityHint?: number | undefined;
|
|
62
|
+
}>, {
|
|
63
|
+
name: string;
|
|
64
|
+
mode: "active" | "audit";
|
|
65
|
+
type: "mutation" | "validation";
|
|
66
|
+
config: Record<string, unknown>;
|
|
67
|
+
enabled: boolean;
|
|
68
|
+
timeoutMs: number;
|
|
69
|
+
phase: "request" | "response";
|
|
70
|
+
failOpen: boolean;
|
|
71
|
+
priorityHint: number;
|
|
72
|
+
model?: {
|
|
73
|
+
provider: string;
|
|
74
|
+
instruction: string;
|
|
75
|
+
model?: string | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
command?: string[] | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
name: string;
|
|
80
|
+
type: "mutation" | "validation";
|
|
81
|
+
phase: "request" | "response";
|
|
82
|
+
mode?: "active" | "audit" | undefined;
|
|
83
|
+
model?: {
|
|
84
|
+
provider: string;
|
|
85
|
+
instruction: string;
|
|
86
|
+
model?: string | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
command?: string[] | undefined;
|
|
89
|
+
config?: Record<string, unknown> | undefined;
|
|
90
|
+
enabled?: boolean | undefined;
|
|
91
|
+
timeoutMs?: number | undefined;
|
|
92
|
+
failOpen?: boolean | undefined;
|
|
93
|
+
priorityHint?: number | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
export declare const AgentInterceptorChainSchema: z.ZodEffects<z.ZodObject<{
|
|
96
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
97
|
+
items: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
98
|
+
name: z.ZodString;
|
|
99
|
+
type: z.ZodEnum<["mutation", "validation"]>;
|
|
100
|
+
phase: z.ZodEnum<["request", "response"]>;
|
|
101
|
+
mode: z.ZodDefault<z.ZodEnum<["active", "audit"]>>;
|
|
102
|
+
failOpen: z.ZodDefault<z.ZodBoolean>;
|
|
103
|
+
priorityHint: z.ZodDefault<z.ZodNumber>;
|
|
104
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
105
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
106
|
+
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
107
|
+
command: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
108
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
provider: z.ZodString;
|
|
110
|
+
model: z.ZodOptional<z.ZodString>;
|
|
111
|
+
instruction: z.ZodString;
|
|
112
|
+
}, "strict", z.ZodTypeAny, {
|
|
113
|
+
provider: string;
|
|
114
|
+
instruction: string;
|
|
115
|
+
model?: string | undefined;
|
|
116
|
+
}, {
|
|
117
|
+
provider: string;
|
|
118
|
+
instruction: string;
|
|
119
|
+
model?: string | undefined;
|
|
120
|
+
}>>;
|
|
121
|
+
}, "strict", z.ZodTypeAny, {
|
|
122
|
+
name: string;
|
|
123
|
+
mode: "active" | "audit";
|
|
124
|
+
type: "mutation" | "validation";
|
|
125
|
+
config: Record<string, unknown>;
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
timeoutMs: number;
|
|
128
|
+
phase: "request" | "response";
|
|
129
|
+
failOpen: boolean;
|
|
130
|
+
priorityHint: number;
|
|
131
|
+
model?: {
|
|
132
|
+
provider: string;
|
|
133
|
+
instruction: string;
|
|
134
|
+
model?: string | undefined;
|
|
135
|
+
} | undefined;
|
|
136
|
+
command?: string[] | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
name: string;
|
|
139
|
+
type: "mutation" | "validation";
|
|
140
|
+
phase: "request" | "response";
|
|
141
|
+
mode?: "active" | "audit" | undefined;
|
|
142
|
+
model?: {
|
|
143
|
+
provider: string;
|
|
144
|
+
instruction: string;
|
|
145
|
+
model?: string | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
command?: string[] | undefined;
|
|
148
|
+
config?: Record<string, unknown> | undefined;
|
|
149
|
+
enabled?: boolean | undefined;
|
|
150
|
+
timeoutMs?: number | undefined;
|
|
151
|
+
failOpen?: boolean | undefined;
|
|
152
|
+
priorityHint?: number | undefined;
|
|
153
|
+
}>, {
|
|
154
|
+
name: string;
|
|
155
|
+
mode: "active" | "audit";
|
|
156
|
+
type: "mutation" | "validation";
|
|
157
|
+
config: Record<string, unknown>;
|
|
158
|
+
enabled: boolean;
|
|
159
|
+
timeoutMs: number;
|
|
160
|
+
phase: "request" | "response";
|
|
161
|
+
failOpen: boolean;
|
|
162
|
+
priorityHint: number;
|
|
163
|
+
model?: {
|
|
164
|
+
provider: string;
|
|
165
|
+
instruction: string;
|
|
166
|
+
model?: string | undefined;
|
|
167
|
+
} | undefined;
|
|
168
|
+
command?: string[] | undefined;
|
|
169
|
+
}, {
|
|
170
|
+
name: string;
|
|
171
|
+
type: "mutation" | "validation";
|
|
172
|
+
phase: "request" | "response";
|
|
173
|
+
mode?: "active" | "audit" | undefined;
|
|
174
|
+
model?: {
|
|
175
|
+
provider: string;
|
|
176
|
+
instruction: string;
|
|
177
|
+
model?: string | undefined;
|
|
178
|
+
} | undefined;
|
|
179
|
+
command?: string[] | undefined;
|
|
180
|
+
config?: Record<string, unknown> | undefined;
|
|
181
|
+
enabled?: boolean | undefined;
|
|
182
|
+
timeoutMs?: number | undefined;
|
|
183
|
+
failOpen?: boolean | undefined;
|
|
184
|
+
priorityHint?: number | undefined;
|
|
185
|
+
}>, "many">;
|
|
186
|
+
}, "strict", z.ZodTypeAny, {
|
|
187
|
+
schemaVersion: 1;
|
|
188
|
+
items: {
|
|
189
|
+
name: string;
|
|
190
|
+
mode: "active" | "audit";
|
|
191
|
+
type: "mutation" | "validation";
|
|
192
|
+
config: Record<string, unknown>;
|
|
193
|
+
enabled: boolean;
|
|
194
|
+
timeoutMs: number;
|
|
195
|
+
phase: "request" | "response";
|
|
196
|
+
failOpen: boolean;
|
|
197
|
+
priorityHint: number;
|
|
198
|
+
model?: {
|
|
199
|
+
provider: string;
|
|
200
|
+
instruction: string;
|
|
201
|
+
model?: string | undefined;
|
|
202
|
+
} | undefined;
|
|
203
|
+
command?: string[] | undefined;
|
|
204
|
+
}[];
|
|
205
|
+
}, {
|
|
206
|
+
schemaVersion: 1;
|
|
207
|
+
items: {
|
|
208
|
+
name: string;
|
|
209
|
+
type: "mutation" | "validation";
|
|
210
|
+
phase: "request" | "response";
|
|
211
|
+
mode?: "active" | "audit" | undefined;
|
|
212
|
+
model?: {
|
|
213
|
+
provider: string;
|
|
214
|
+
instruction: string;
|
|
215
|
+
model?: string | undefined;
|
|
216
|
+
} | undefined;
|
|
217
|
+
command?: string[] | undefined;
|
|
218
|
+
config?: Record<string, unknown> | undefined;
|
|
219
|
+
enabled?: boolean | undefined;
|
|
220
|
+
timeoutMs?: number | undefined;
|
|
221
|
+
failOpen?: boolean | undefined;
|
|
222
|
+
priorityHint?: number | undefined;
|
|
223
|
+
}[];
|
|
224
|
+
}>, {
|
|
225
|
+
schemaVersion: 1;
|
|
226
|
+
items: {
|
|
227
|
+
name: string;
|
|
228
|
+
mode: "active" | "audit";
|
|
229
|
+
type: "mutation" | "validation";
|
|
230
|
+
config: Record<string, unknown>;
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
timeoutMs: number;
|
|
233
|
+
phase: "request" | "response";
|
|
234
|
+
failOpen: boolean;
|
|
235
|
+
priorityHint: number;
|
|
236
|
+
model?: {
|
|
237
|
+
provider: string;
|
|
238
|
+
instruction: string;
|
|
239
|
+
model?: string | undefined;
|
|
240
|
+
} | undefined;
|
|
241
|
+
command?: string[] | undefined;
|
|
242
|
+
}[];
|
|
243
|
+
}, {
|
|
244
|
+
schemaVersion: 1;
|
|
245
|
+
items: {
|
|
246
|
+
name: string;
|
|
247
|
+
type: "mutation" | "validation";
|
|
248
|
+
phase: "request" | "response";
|
|
249
|
+
mode?: "active" | "audit" | undefined;
|
|
250
|
+
model?: {
|
|
251
|
+
provider: string;
|
|
252
|
+
instruction: string;
|
|
253
|
+
model?: string | undefined;
|
|
254
|
+
} | undefined;
|
|
255
|
+
command?: string[] | undefined;
|
|
256
|
+
config?: Record<string, unknown> | undefined;
|
|
257
|
+
enabled?: boolean | undefined;
|
|
258
|
+
timeoutMs?: number | undefined;
|
|
259
|
+
failOpen?: boolean | undefined;
|
|
260
|
+
priorityHint?: number | undefined;
|
|
261
|
+
}[];
|
|
262
|
+
}>;
|
|
263
|
+
export declare class AgentInterceptorConfigError extends Error {
|
|
264
|
+
readonly code = "INTERCEPTOR_CONFIG_INVALID";
|
|
265
|
+
constructor(agentId: string, message: string);
|
|
266
|
+
}
|
|
267
|
+
export declare function parseAgentInterceptorItems(agentId: string, raw: unknown): AgentInterceptorItem[] | undefined;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export type InterceptorPhase = 'request' | 'response';
|
|
2
|
+
export type InterceptorType = 'mutation' | 'validation';
|
|
3
|
+
export type InterceptorMode = 'active' | 'audit';
|
|
4
|
+
export type InterceptorSeverity = 'error' | 'warn' | 'info';
|
|
5
|
+
export type InterceptorOutcome = 'applied' | 'unchanged' | 'blocked' | 'audit' | 'bypassed' | 'failed';
|
|
6
|
+
export declare const INTERCEPTOR_CONFIG_INVALID = "INTERCEPTOR_CONFIG_INVALID";
|
|
7
|
+
export declare const INTERCEPTOR_BLOCKED = "INTERCEPTOR_BLOCKED";
|
|
8
|
+
export declare const INTERCEPTOR_STOPPED = "INTERCEPTOR_STOPPED";
|
|
9
|
+
export declare const INTERCEPTOR_FAILED = "INTERCEPTOR_FAILED";
|
|
10
|
+
export interface AgentInterceptorItem {
|
|
11
|
+
name: string;
|
|
12
|
+
type: InterceptorType;
|
|
13
|
+
phase: InterceptorPhase;
|
|
14
|
+
mode: InterceptorMode;
|
|
15
|
+
failOpen: boolean;
|
|
16
|
+
priorityHint: number;
|
|
17
|
+
timeoutMs: number;
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
config: Record<string, unknown>;
|
|
20
|
+
command?: string[];
|
|
21
|
+
model?: {
|
|
22
|
+
provider: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
instruction: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface InterceptorMessage {
|
|
28
|
+
role: string;
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
export interface InterceptorVerdict {
|
|
32
|
+
valid: boolean;
|
|
33
|
+
severity?: InterceptorSeverity;
|
|
34
|
+
messages: Array<{
|
|
35
|
+
message: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface InterceptorError {
|
|
39
|
+
code: number | string;
|
|
40
|
+
message: string;
|
|
41
|
+
}
|
|
42
|
+
export interface InterceptorUsage {
|
|
43
|
+
inputTokens: number;
|
|
44
|
+
outputTokens: number;
|
|
45
|
+
cachedInputTokens: number;
|
|
46
|
+
costUsd: number;
|
|
47
|
+
}
|
|
48
|
+
export interface InterceptorStepLog {
|
|
49
|
+
name: string;
|
|
50
|
+
type: InterceptorType;
|
|
51
|
+
phase: InterceptorPhase;
|
|
52
|
+
mode: InterceptorMode;
|
|
53
|
+
outcome: InterceptorOutcome;
|
|
54
|
+
failOpen: boolean;
|
|
55
|
+
durationMs: number;
|
|
56
|
+
error?: InterceptorError;
|
|
57
|
+
before: string;
|
|
58
|
+
after?: string;
|
|
59
|
+
verdict?: InterceptorVerdict;
|
|
60
|
+
usage?: InterceptorUsage;
|
|
61
|
+
stderr?: string;
|
|
62
|
+
}
|
|
63
|
+
export type InterceptorInvocation = {
|
|
64
|
+
ok: true;
|
|
65
|
+
result: unknown;
|
|
66
|
+
durationMs: number;
|
|
67
|
+
usage?: InterceptorUsage;
|
|
68
|
+
stderr?: string;
|
|
69
|
+
} | {
|
|
70
|
+
ok: false;
|
|
71
|
+
code: number | string;
|
|
72
|
+
message: string;
|
|
73
|
+
durationMs: number;
|
|
74
|
+
usage?: InterceptorUsage;
|
|
75
|
+
stderr?: string;
|
|
76
|
+
};
|
|
77
|
+
export interface InterceptorLaneRun {
|
|
78
|
+
phase: InterceptorPhase;
|
|
79
|
+
status: 'passed' | 'blocked' | 'stopped';
|
|
80
|
+
text: string;
|
|
81
|
+
changed: boolean;
|
|
82
|
+
steps: InterceptorStepLog[];
|
|
83
|
+
blocked?: {
|
|
84
|
+
step: string;
|
|
85
|
+
code: typeof INTERCEPTOR_BLOCKED;
|
|
86
|
+
message: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
package/dist/app/app.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UiContentMediaType } from './content-media-types.js';
|
|
2
|
+
import type { AppScheduleDirective, AppScheduleSnapshot, ToolScheduleDeclaration } from './schedule-contract.js';
|
|
2
3
|
export type JsonObject = Record<string, unknown>;
|
|
3
4
|
export type JsonSchema = Readonly<{
|
|
4
5
|
type: 'object';
|
|
@@ -66,11 +67,12 @@ export interface ToolOptions {
|
|
|
66
67
|
allow: readonly string[];
|
|
67
68
|
}>;
|
|
68
69
|
readonly content?: ToolContentDeclaration;
|
|
70
|
+
readonly schedule?: ToolScheduleDeclaration;
|
|
69
71
|
}
|
|
70
72
|
export interface AppContext {
|
|
71
73
|
readonly instanceId: string;
|
|
72
74
|
readonly threadId: string | null;
|
|
73
|
-
readonly actor: 'user' | 'agent';
|
|
75
|
+
readonly actor: 'user' | 'agent' | 'schedule';
|
|
74
76
|
readonly requestId: string;
|
|
75
77
|
readonly nowMs: number;
|
|
76
78
|
}
|
|
@@ -78,6 +80,7 @@ export interface AppRuntimeOptions<State extends JsonObject = JsonObject> {
|
|
|
78
80
|
readonly state?: State;
|
|
79
81
|
readonly workspaceRoot: string;
|
|
80
82
|
readonly context?: AppContext;
|
|
83
|
+
readonly schedule?: AppScheduleSnapshot;
|
|
81
84
|
}
|
|
82
85
|
export type AppFailureOutcome = 'failed' | 'rejected';
|
|
83
86
|
export interface AppErrorMapping {
|
|
@@ -111,8 +114,13 @@ export declare class CrewXApp<State extends JsonObject = JsonObject> {
|
|
|
111
114
|
private answerBody;
|
|
112
115
|
private answerRange;
|
|
113
116
|
private readonly callContext;
|
|
117
|
+
private readonly callSchedule;
|
|
118
|
+
private scheduleDirective;
|
|
114
119
|
readonly workspaceRoot: string;
|
|
115
120
|
constructor(options?: AppRuntimeOptions<State>);
|
|
121
|
+
get schedule(): AppScheduleSnapshot | undefined;
|
|
122
|
+
requestSchedule(enabled: boolean): void;
|
|
123
|
+
get didRequestSchedule(): AppScheduleDirective | undefined;
|
|
116
124
|
get context(): AppContext;
|
|
117
125
|
get state(): DeepReadonly<State>;
|
|
118
126
|
get didSetState(): boolean;
|
|
@@ -142,6 +150,7 @@ export type CrewXAppConstructor = (new (options: AppRuntimeOptions) => CrewXApp)
|
|
|
142
150
|
type DecoratedMethod<This, Input extends object, Result extends ToolResult> = (this: This, input: Input, content: ToolContent) => Result;
|
|
143
151
|
export declare function Tool(options: ToolOptions): <This, Input extends object, Result extends ToolResult>(_method: DecoratedMethod<This, Input, Result>, context: ClassMethodDecoratorContext<This, DecoratedMethod<This, Input, Result>>) => void;
|
|
144
152
|
export declare function getToolDeclarations(appClass: CrewXAppConstructor): ToolDeclaration[];
|
|
153
|
+
export declare function declaresSchedule(appClass: CrewXAppConstructor): boolean;
|
|
145
154
|
export declare function generateToolDeclarations(appClass: CrewXAppConstructor): JsonObject[];
|
|
146
155
|
export declare function generateManifest(appClass: CrewXAppConstructor, backendCommand: readonly string[]): JsonObject;
|
|
147
156
|
export declare function isPlainRecord(value: unknown): value is JsonObject;
|
package/dist/app/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { AppError, CrewXApp, Tool, generateManifest, generateToolDeclarations, getToolDeclarations, } from './app.js';
|
|
2
2
|
export type { AppContext, AppDefinition, AppErrorContext, AppErrorMapping, AppErrorOptions, AppFailureOutcome, AppRuntimeOptions, ContentRange, ContentRangeRequest, CrewXAppConstructor, DeepReadonly, JsonObject, JsonSchema, ToolContent, ToolContentDeclaration, ToolContentInput, ToolContentOutput, ToolDeclaration, ToolOptions, ToolResult, } from './app.js';
|
|
3
3
|
export { readAppContext } from './context.js';
|
|
4
|
+
export { APP_SCHEDULE_ACTOR_KIND, APP_SCHEDULE_INERT_COMMAND, APP_SCHEDULE_INSTANCE_PREFIX, APP_SCHEDULE_INTERVALS_MINUTES, APP_SCHEDULE_MAX_PER_APP, APP_SCHEDULE_PERIODIC_REASONS, APP_SCHEDULE_TIMEOUT_MS, SCHEDULE_TRIGGERS, isAppSchedulePeriodicReason, isAppScheduleCode, isAppScheduleIntervalMinutes, isAppScheduleTimeoutMs, } from './schedule-contract.js';
|
|
5
|
+
export type { AppScheduleDirective, AppScheduleIntervalMinutes, AppSchedulePeriodic, AppSchedulePeriodicReason, AppScheduleRunVerdict, AppScheduleSnapshot, AppScheduleStatus, ScheduleTrigger, ToolScheduleDeclaration, } from './schedule-contract.js';
|
|
4
6
|
export { APP_TOOLS_FILE, APP_TOOLS_SCHEMA_VERSION, APP_TOOL_ENTRY } from './tool-mode.js';
|
|
5
7
|
export { SKILL_BACKEND_ENV_NAMES, isSkillBackendEnv } from './backend-env.js';
|
|
6
8
|
export type { SkillBackendEnvName } from './backend-env.js';
|