@gencode/uni 0.2.0
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/CHANGELOG.md +15 -0
- package/README.md +50 -0
- package/dist/shared/src/agent-progress.d.ts +133 -0
- package/dist/shared/src/agent-progress.d.ts.map +1 -0
- package/dist/shared/src/agent-progress.js +4 -0
- package/dist/shared/src/agent-progress.js.map +1 -0
- package/dist/shared/src/context-protocol.d.ts +83 -0
- package/dist/shared/src/context-protocol.d.ts.map +1 -0
- package/dist/shared/src/context-protocol.js +2 -0
- package/dist/shared/src/context-protocol.js.map +1 -0
- package/dist/shared/src/goal.d.ts +50 -0
- package/dist/shared/src/goal.d.ts.map +1 -0
- package/dist/shared/src/goal.js +11 -0
- package/dist/shared/src/goal.js.map +1 -0
- package/dist/shared/src/hitl.d.ts +214 -0
- package/dist/shared/src/hitl.d.ts.map +1 -0
- package/dist/shared/src/hitl.js +205 -0
- package/dist/shared/src/hitl.js.map +1 -0
- package/dist/shared/src/index.d.ts +16 -0
- package/dist/shared/src/index.d.ts.map +1 -0
- package/dist/shared/src/index.js +12 -0
- package/dist/shared/src/index.js.map +1 -0
- package/dist/shared/src/run-events.d.ts +129 -0
- package/dist/shared/src/run-events.d.ts.map +1 -0
- package/dist/shared/src/run-events.js +2 -0
- package/dist/shared/src/run-events.js.map +1 -0
- package/dist/shared/src/session.d.ts +37 -0
- package/dist/shared/src/session.d.ts.map +1 -0
- package/dist/shared/src/session.js +2 -0
- package/dist/shared/src/session.js.map +1 -0
- package/dist/shared/src/task-display.d.ts +3 -0
- package/dist/shared/src/task-display.d.ts.map +1 -0
- package/dist/shared/src/task-display.js +41 -0
- package/dist/shared/src/task-display.js.map +1 -0
- package/dist/shared/src/ui-tool.d.ts +94 -0
- package/dist/shared/src/ui-tool.d.ts.map +1 -0
- package/dist/shared/src/ui-tool.js +39 -0
- package/dist/shared/src/ui-tool.js.map +1 -0
- package/dist/uni/src/auth/api-key.d.ts +3 -0
- package/dist/uni/src/auth/api-key.d.ts.map +1 -0
- package/dist/uni/src/auth/api-key.js +8 -0
- package/dist/uni/src/auth/api-key.js.map +1 -0
- package/dist/uni/src/bin.d.ts +3 -0
- package/dist/uni/src/bin.d.ts.map +1 -0
- package/dist/uni/src/bin.js +4 -0
- package/dist/uni/src/bin.js.map +1 -0
- package/dist/uni/src/events/normalizer.d.ts +4 -0
- package/dist/uni/src/events/normalizer.d.ts.map +1 -0
- package/dist/uni/src/events/normalizer.js +72 -0
- package/dist/uni/src/events/normalizer.js.map +1 -0
- package/dist/uni/src/events/provider-events.d.ts +8 -0
- package/dist/uni/src/events/provider-events.d.ts.map +1 -0
- package/dist/uni/src/events/provider-events.js +317 -0
- package/dist/uni/src/events/provider-events.js.map +1 -0
- package/dist/uni/src/hooks.d.ts +8 -0
- package/dist/uni/src/hooks.d.ts.map +1 -0
- package/dist/uni/src/hooks.js +13 -0
- package/dist/uni/src/hooks.js.map +1 -0
- package/dist/uni/src/index.d.ts +10 -0
- package/dist/uni/src/index.d.ts.map +1 -0
- package/dist/uni/src/index.js +8 -0
- package/dist/uni/src/index.js.map +1 -0
- package/dist/uni/src/program.d.ts +3 -0
- package/dist/uni/src/program.d.ts.map +1 -0
- package/dist/uni/src/program.js +140 -0
- package/dist/uni/src/program.js.map +1 -0
- package/dist/uni/src/providers/acp.d.ts +3 -0
- package/dist/uni/src/providers/acp.d.ts.map +1 -0
- package/dist/uni/src/providers/acp.js +33 -0
- package/dist/uni/src/providers/acp.js.map +1 -0
- package/dist/uni/src/providers/claude-code.d.ts +3 -0
- package/dist/uni/src/providers/claude-code.d.ts.map +1 -0
- package/dist/uni/src/providers/claude-code.js +87 -0
- package/dist/uni/src/providers/claude-code.js.map +1 -0
- package/dist/uni/src/providers/codex.d.ts +3 -0
- package/dist/uni/src/providers/codex.d.ts.map +1 -0
- package/dist/uni/src/providers/codex.js +71 -0
- package/dist/uni/src/providers/codex.js.map +1 -0
- package/dist/uni/src/providers/opencode.d.ts +3 -0
- package/dist/uni/src/providers/opencode.d.ts.map +1 -0
- package/dist/uni/src/providers/opencode.js +47 -0
- package/dist/uni/src/providers/opencode.js.map +1 -0
- package/dist/uni/src/providers/pi.d.ts +3 -0
- package/dist/uni/src/providers/pi.d.ts.map +1 -0
- package/dist/uni/src/providers/pi.js +42 -0
- package/dist/uni/src/providers/pi.js.map +1 -0
- package/dist/uni/src/providers/registry.d.ts +3 -0
- package/dist/uni/src/providers/registry.d.ts.map +1 -0
- package/dist/uni/src/providers/registry.js +25 -0
- package/dist/uni/src/providers/registry.js.map +1 -0
- package/dist/uni/src/providers/spawned-provider.d.ts +22 -0
- package/dist/uni/src/providers/spawned-provider.d.ts.map +1 -0
- package/dist/uni/src/providers/spawned-provider.js +109 -0
- package/dist/uni/src/providers/spawned-provider.js.map +1 -0
- package/dist/uni/src/providers/types.d.ts +6 -0
- package/dist/uni/src/providers/types.d.ts.map +1 -0
- package/dist/uni/src/providers/types.js +2 -0
- package/dist/uni/src/providers/types.js.map +1 -0
- package/dist/uni/src/run.d.ts +3 -0
- package/dist/uni/src/run.d.ts.map +1 -0
- package/dist/uni/src/run.js +446 -0
- package/dist/uni/src/run.js.map +1 -0
- package/dist/uni/src/runtime-config.d.ts +40 -0
- package/dist/uni/src/runtime-config.d.ts.map +1 -0
- package/dist/uni/src/runtime-config.js +203 -0
- package/dist/uni/src/runtime-config.js.map +1 -0
- package/dist/uni/src/session/input.d.ts +3 -0
- package/dist/uni/src/session/input.d.ts.map +1 -0
- package/dist/uni/src/session/input.js +147 -0
- package/dist/uni/src/session/input.js.map +1 -0
- package/dist/uni/src/session/logger.d.ts +16 -0
- package/dist/uni/src/session/logger.d.ts.map +1 -0
- package/dist/uni/src/session/logger.js +66 -0
- package/dist/uni/src/session/logger.js.map +1 -0
- package/dist/uni/src/session/session-state.d.ts +19 -0
- package/dist/uni/src/session/session-state.d.ts.map +1 -0
- package/dist/uni/src/session/session-state.js +13 -0
- package/dist/uni/src/session/session-state.js.map +1 -0
- package/dist/uni/src/session/session-store.d.ts +23 -0
- package/dist/uni/src/session/session-store.d.ts.map +1 -0
- package/dist/uni/src/session/session-store.js +36 -0
- package/dist/uni/src/session/session-store.js.map +1 -0
- package/dist/uni/src/transports/composite-sink.d.ts +9 -0
- package/dist/uni/src/transports/composite-sink.d.ts.map +1 -0
- package/dist/uni/src/transports/composite-sink.js +17 -0
- package/dist/uni/src/transports/composite-sink.js.map +1 -0
- package/dist/uni/src/transports/event-sink.d.ts +6 -0
- package/dist/uni/src/transports/event-sink.d.ts.map +1 -0
- package/dist/uni/src/transports/event-sink.js +2 -0
- package/dist/uni/src/transports/event-sink.js.map +1 -0
- package/dist/uni/src/transports/http-callback-sink.d.ts +9 -0
- package/dist/uni/src/transports/http-callback-sink.d.ts.map +1 -0
- package/dist/uni/src/transports/http-callback-sink.js +20 -0
- package/dist/uni/src/transports/http-callback-sink.js.map +1 -0
- package/dist/uni/src/transports/websocket-auth.d.ts +8 -0
- package/dist/uni/src/transports/websocket-auth.d.ts.map +1 -0
- package/dist/uni/src/transports/websocket-auth.js +9 -0
- package/dist/uni/src/transports/websocket-auth.js.map +1 -0
- package/dist/uni/src/transports/websocket-sink.d.ts +24 -0
- package/dist/uni/src/transports/websocket-sink.d.ts.map +1 -0
- package/dist/uni/src/transports/websocket-sink.js +205 -0
- package/dist/uni/src/transports/websocket-sink.js.map +1 -0
- package/dist/uni/src/types.d.ts +239 -0
- package/dist/uni/src/types.d.ts.map +1 -0
- package/dist/uni/src/types.js +2 -0
- package/dist/uni/src/types.js.map +1 -0
- package/package.json +38 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @gencode/uni
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 26ad74d: Add a standalone `@gencode/uni` package for unified multi-agent runtime execution with provider selection, callback delivery, websocket streaming, and shared event normalization.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 26ad74d: Normalize provider tool call events for Claude Code and OpenCode, and add uni runtime tool hooks for before/after tool call observability.
|
|
12
|
+
|
|
13
|
+
## 0.1.0
|
|
14
|
+
|
|
15
|
+
- Initial release placeholder.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @gencode/uni
|
|
2
|
+
|
|
3
|
+
Independent unified agent runtime for AIMax.
|
|
4
|
+
|
|
5
|
+
`@gencode/uni` does not reuse the existing `@gencode/cli` or `@gencode/agents`
|
|
6
|
+
run pipeline. It provides:
|
|
7
|
+
|
|
8
|
+
- `runUni()` for one-shot execution
|
|
9
|
+
- pluggable runtime agents (`claude-code`, `codex`, `opencode`, `pi`, `acp`)
|
|
10
|
+
- callback and websocket transports
|
|
11
|
+
- a normalization layer that maps provider-native output to
|
|
12
|
+
`@gencode/shared` run events
|
|
13
|
+
|
|
14
|
+
This package is intentionally standalone. Existing CLI integration remains a
|
|
15
|
+
separate concern.
|
|
16
|
+
|
|
17
|
+
## CLI
|
|
18
|
+
|
|
19
|
+
`@gencode/uni` also exposes a standalone binary:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
gencode-uni run \
|
|
23
|
+
--runtime-agent codex \
|
|
24
|
+
--data-dir /data/user1 \
|
|
25
|
+
--message "Review this repository" \
|
|
26
|
+
--runtime-cli-path "codex --proxy" \
|
|
27
|
+
--runtime-mode full-auto \
|
|
28
|
+
--runtime-provider-base-url https://relay.example.com/v1
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The command keeps the current `aimax run` parameter surface for core fields and
|
|
32
|
+
adds runtime-specific flags inspired by `reference/cc-connect`, such as:
|
|
33
|
+
|
|
34
|
+
- `--runtime-cli-path`
|
|
35
|
+
- `--runtime-cli-args-flag`
|
|
36
|
+
- `--runtime-mode`
|
|
37
|
+
- `--runtime-reasoning-effort`
|
|
38
|
+
- `--runtime-router-url`
|
|
39
|
+
- `--runtime-router-api-key`
|
|
40
|
+
- `--runtime-codex-home`
|
|
41
|
+
- `--runtime-provider-env`
|
|
42
|
+
- `--runtime-provider-header`
|
|
43
|
+
|
|
44
|
+
## Smoke Tests
|
|
45
|
+
|
|
46
|
+
Provider-specific helper scripts live in `scripts/`:
|
|
47
|
+
|
|
48
|
+
- `scripts/test-claude-run.sh`
|
|
49
|
+
- `scripts/test-codex-run.sh`
|
|
50
|
+
- `scripts/test-opencode-run.sh`
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export type AgentProgressEventBase = {
|
|
2
|
+
sessionId?: string;
|
|
3
|
+
messageId?: string;
|
|
4
|
+
parentSessionId?: string;
|
|
5
|
+
depth?: number;
|
|
6
|
+
};
|
|
7
|
+
export type AgentCustomProgressEvent = AgentProgressEventBase & {
|
|
8
|
+
type: "custom";
|
|
9
|
+
pluginId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
data?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
export type AgentModelRequestEvent = AgentProgressEventBase & {
|
|
15
|
+
type: "model_request";
|
|
16
|
+
model: string;
|
|
17
|
+
provider: string;
|
|
18
|
+
systemPrompt: string;
|
|
19
|
+
tools: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
parameters?: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
requestJson: unknown;
|
|
25
|
+
};
|
|
26
|
+
export type AgentDiagnosticLevel = "info" | "warn" | "error";
|
|
27
|
+
export type AgentDiagnosticScope = "runner" | "session" | "plugin" | "skill" | "memory" | "tool";
|
|
28
|
+
export type AgentDiagnosticEvent = AgentProgressEventBase & {
|
|
29
|
+
type: "diagnostic";
|
|
30
|
+
level: AgentDiagnosticLevel;
|
|
31
|
+
scope: AgentDiagnosticScope;
|
|
32
|
+
phase: string;
|
|
33
|
+
message: string;
|
|
34
|
+
details?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
export type AgentProgressEvent = (AgentProgressEventBase & {
|
|
37
|
+
type: "start";
|
|
38
|
+
message: string;
|
|
39
|
+
}) | (AgentProgressEventBase & {
|
|
40
|
+
type: "text";
|
|
41
|
+
text: string;
|
|
42
|
+
}) | (AgentProgressEventBase & {
|
|
43
|
+
type: "stream_text_delta";
|
|
44
|
+
text: string;
|
|
45
|
+
}) | (AgentProgressEventBase & {
|
|
46
|
+
type: "bootstrap";
|
|
47
|
+
phase: "checking" | "initializing" | "initialized" | "ready";
|
|
48
|
+
dataDir: string;
|
|
49
|
+
}) | (AgentProgressEventBase & {
|
|
50
|
+
type: "session_reset";
|
|
51
|
+
action: "new" | "reset";
|
|
52
|
+
previousSessionId?: string;
|
|
53
|
+
message: string;
|
|
54
|
+
}) | (AgentProgressEventBase & {
|
|
55
|
+
type: "tool_start";
|
|
56
|
+
toolCallId: string;
|
|
57
|
+
name: string;
|
|
58
|
+
input: unknown;
|
|
59
|
+
}) | (AgentProgressEventBase & {
|
|
60
|
+
type: "tool_end";
|
|
61
|
+
toolCallId: string;
|
|
62
|
+
name: string;
|
|
63
|
+
input: unknown;
|
|
64
|
+
output: string;
|
|
65
|
+
isError: boolean;
|
|
66
|
+
}) | (AgentProgressEventBase & {
|
|
67
|
+
type: "compaction";
|
|
68
|
+
reason: string;
|
|
69
|
+
layer?: "L1" | "L2" | "L3" | "L4" | "L5" | "L6";
|
|
70
|
+
strategy?: string;
|
|
71
|
+
estimatedTokensFreed?: number;
|
|
72
|
+
affectedEntries?: number;
|
|
73
|
+
snapshotVersion?: number;
|
|
74
|
+
}) | (AgentProgressEventBase & {
|
|
75
|
+
type: "memory_changed";
|
|
76
|
+
reason: string;
|
|
77
|
+
files: string[];
|
|
78
|
+
source: "memory" | "sessions";
|
|
79
|
+
providerId?: string;
|
|
80
|
+
timestamp: string;
|
|
81
|
+
}) | (AgentProgressEventBase & {
|
|
82
|
+
type: "skill_used";
|
|
83
|
+
skillName: string;
|
|
84
|
+
agent: string;
|
|
85
|
+
taskId: string;
|
|
86
|
+
}) | AgentCustomProgressEvent | AgentModelRequestEvent | (AgentProgressEventBase & {
|
|
87
|
+
type: "error";
|
|
88
|
+
message: string;
|
|
89
|
+
}) | (AgentProgressEventBase & {
|
|
90
|
+
type: "subagent_spawn";
|
|
91
|
+
childSessionId: string;
|
|
92
|
+
task: string;
|
|
93
|
+
label?: string;
|
|
94
|
+
}) | (AgentProgressEventBase & {
|
|
95
|
+
type: "subagent_complete";
|
|
96
|
+
childSessionId: string;
|
|
97
|
+
task: string;
|
|
98
|
+
status: "done" | "error" | "killed";
|
|
99
|
+
}) | (AgentProgressEventBase & {
|
|
100
|
+
type: "hitl_requested";
|
|
101
|
+
request: import("./hitl.js").HitlRequest;
|
|
102
|
+
}) | (AgentProgressEventBase & {
|
|
103
|
+
type: "hitl_resumed";
|
|
104
|
+
requestId: string;
|
|
105
|
+
resolution: import("./hitl.js").HitlResolution;
|
|
106
|
+
}) | (AgentProgressEventBase & {
|
|
107
|
+
type: "hitl_expired";
|
|
108
|
+
requestId: string;
|
|
109
|
+
reason: string;
|
|
110
|
+
}) | (AgentProgressEventBase & {
|
|
111
|
+
type: "hitl_cancelled";
|
|
112
|
+
requestId: string;
|
|
113
|
+
reason?: string;
|
|
114
|
+
}) | (AgentProgressEventBase & {
|
|
115
|
+
type: "title_updated";
|
|
116
|
+
title: string;
|
|
117
|
+
}) | (AgentProgressEventBase & {
|
|
118
|
+
type: "goal_updated";
|
|
119
|
+
action: string;
|
|
120
|
+
goalId?: string;
|
|
121
|
+
goalStatus: import("./goal.js").GoalStatus | null;
|
|
122
|
+
}) | (AgentProgressEventBase & {
|
|
123
|
+
type: "ui_tool_request";
|
|
124
|
+
request: import("./ui-tool.js").UiToolRequest;
|
|
125
|
+
}) | (AgentProgressEventBase & {
|
|
126
|
+
type: "ui_tool_result";
|
|
127
|
+
requestId: string;
|
|
128
|
+
toolCallId: string;
|
|
129
|
+
toolName: string;
|
|
130
|
+
values: Record<string, unknown>;
|
|
131
|
+
}) | AgentDiagnosticEvent;
|
|
132
|
+
export declare function isAgentDiagnosticEvent(event: AgentProgressEvent): event is AgentDiagnosticEvent;
|
|
133
|
+
//# sourceMappingURL=agent-progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-progress.d.ts","sourceRoot":"","sources":["../../../../shared/src/agent-progress.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,sBAAsB,GAAG;IAC9D,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,GAAG;IAC5D,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC,CAAC;IACH,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjG,MAAM,MAAM,o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CAAC;CACjC,CAAC,GACA,oBAAoB,CAAC;AAEzB,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,IAAI,oBAAoB,CAE/F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-progress.js","sourceRoot":"","sources":["../../../../shared/src/agent-progress.ts"],"names":[],"mappings":"AA8IA,MAAM,UAAU,sBAAsB,CAAC,KAAyB;IAC9D,OAAO,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type ReadStateRecord = {
|
|
2
|
+
path: string;
|
|
3
|
+
offset?: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
contentHash: string;
|
|
6
|
+
lineCount: number;
|
|
7
|
+
capturedAt: string;
|
|
8
|
+
lastModifiedMs: number;
|
|
9
|
+
};
|
|
10
|
+
export type ToolResultReference = {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
toolCallId: string;
|
|
13
|
+
toolName: string;
|
|
14
|
+
storagePath: string;
|
|
15
|
+
preview: string;
|
|
16
|
+
originalChars: number;
|
|
17
|
+
truncated: boolean;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
};
|
|
20
|
+
export type CompressionLayer = "L1" | "L2" | "L3" | "L4" | "L5" | "L6";
|
|
21
|
+
export type ToolResultBudgetRecord = {
|
|
22
|
+
toolCallId: string;
|
|
23
|
+
toolName: string;
|
|
24
|
+
originalChars: number;
|
|
25
|
+
storedChars: number;
|
|
26
|
+
previewChars: number;
|
|
27
|
+
strategy: "persist";
|
|
28
|
+
createdAt: string;
|
|
29
|
+
};
|
|
30
|
+
export type SnipRecord = {
|
|
31
|
+
toolCallId: string;
|
|
32
|
+
toolName: string;
|
|
33
|
+
originalChars: number;
|
|
34
|
+
retainedChars: number;
|
|
35
|
+
reason: "context_dedup" | "history_snip" | "microcompact";
|
|
36
|
+
createdAt: string;
|
|
37
|
+
};
|
|
38
|
+
export type CollapseSpan = {
|
|
39
|
+
id: string;
|
|
40
|
+
layer: "L5";
|
|
41
|
+
startEntryIndex: number;
|
|
42
|
+
endEntryIndex: number;
|
|
43
|
+
toolNames: string[];
|
|
44
|
+
summary: string;
|
|
45
|
+
sourceCount: number;
|
|
46
|
+
estimatedTokensFreed: number;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
};
|
|
49
|
+
export type SessionMemorySnapshot = {
|
|
50
|
+
version: 1;
|
|
51
|
+
summary: string;
|
|
52
|
+
generatedAt: string;
|
|
53
|
+
sourceEntryCount: number;
|
|
54
|
+
tokenEstimate: number;
|
|
55
|
+
trigger: "threshold" | "autocompact" | "manual";
|
|
56
|
+
};
|
|
57
|
+
export type ModelUsageCheckpoint = {
|
|
58
|
+
version: 1;
|
|
59
|
+
model: string;
|
|
60
|
+
inputTokens: number;
|
|
61
|
+
outputTokens: number;
|
|
62
|
+
totalTokens: number;
|
|
63
|
+
coveredTranscriptEntryCount: number;
|
|
64
|
+
recordedAt: string;
|
|
65
|
+
};
|
|
66
|
+
export type ContextCompactionState = {
|
|
67
|
+
sessionMemory?: SessionMemorySnapshot;
|
|
68
|
+
modelUsage?: ModelUsageCheckpoint;
|
|
69
|
+
budgets: ToolResultBudgetRecord[];
|
|
70
|
+
snips: SnipRecord[];
|
|
71
|
+
collapseSpans: CollapseSpan[];
|
|
72
|
+
consecutiveAutocompactFailures: number;
|
|
73
|
+
lastCompactionAt?: string;
|
|
74
|
+
lastCompactionLayer?: CompressionLayer;
|
|
75
|
+
};
|
|
76
|
+
export type SessionContextSnapshot = {
|
|
77
|
+
version: 2;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
readStates: ReadStateRecord[];
|
|
80
|
+
toolResults: ToolResultReference[];
|
|
81
|
+
compaction: ContextCompactionState;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=context-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-protocol.d.ts","sourceR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AAM,CAAC;IAClB,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,UAAU,EAAE,sBAAsB,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-protocol.js","sourceRoot":"","sources":["../../../../shared/src/context-protocol.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thread Goal types for @gencode/shared.
|
|
3
|
+
*
|
|
4
|
+
* Defines the cross-package contract for the lightweight thread goal system.
|
|
5
|
+
* See source/执行约束.md and artifacts/实现计划.md for design rationale.
|
|
6
|
+
*/
|
|
7
|
+
/** Maximum characters for inline objective in goal.json */
|
|
8
|
+
export declare const MAX_GOAL_OBJECTIVE_CHARS = 4000;
|
|
9
|
+
/** Maximum continuations per single runAgent call */
|
|
10
|
+
export declare const MAX_GOAL_CONTINUATIONS_PER_RUN = 3;
|
|
11
|
+
/**
|
|
12
|
+
* Goal status enumeration.
|
|
13
|
+
*
|
|
14
|
+
* - `active`: Being pursued; continuation turns are eligible.
|
|
15
|
+
* - `paused`: Suspended by user or system (e.g. interrupt, limit reached).
|
|
16
|
+
* - `budget_limited`: Token budget exhausted; system-steered wrap-up.
|
|
17
|
+
* - `complete`: Declared finished via model `update_goal(status=complete)`.
|
|
18
|
+
*/
|
|
19
|
+
export type GoalStatus = "active" | "paused" | "budget_limited" | "complete";
|
|
20
|
+
/**
|
|
21
|
+
* Persisted thread goal record.
|
|
22
|
+
*
|
|
23
|
+
* Stored as `{sessionDir}/goal.json`. The `objective` field is the canonical
|
|
24
|
+
* source of truth for what the model is asked to pursue. When the objective
|
|
25
|
+
* exceeds MAX_GOAL_OBJECTIVE_CHARS, the full text is stored in an adjacent
|
|
26
|
+
* `goal-objective.md` file and `objectiveRef` points to it.
|
|
27
|
+
*/
|
|
28
|
+
export interface ThreadGoal {
|
|
29
|
+
/** UUID v4; replaced on each set or replace. */
|
|
30
|
+
goalId: string;
|
|
31
|
+
/** Inline objective text (≤4000 chars) or summary when objectiveRef is set. */
|
|
32
|
+
objective: string;
|
|
33
|
+
/** Relative path to `goal-objective.md` for objectives > MAX_GOAL_OBJECTIVE_CHARS. */
|
|
34
|
+
objectiveRef?: string;
|
|
35
|
+
/** Current status. */
|
|
36
|
+
status: GoalStatus;
|
|
37
|
+
/** Optional positive token budget; null means unlimited. */
|
|
38
|
+
tokenBudget: number | null;
|
|
39
|
+
/** Cumulative token consumption (non-cached input + output). */
|
|
40
|
+
tokensUsed: number;
|
|
41
|
+
/** Cumulative wall-clock seconds since goal creation (best-effort). */
|
|
42
|
+
timeUsedSeconds: number;
|
|
43
|
+
/** ISO 8601 creation timestamp. */
|
|
44
|
+
createdAt: string;
|
|
45
|
+
/** ISO 8601 last-updated timestamp. */
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
/** When true, runner injects one objective-updated steering turn then clears. */
|
|
48
|
+
pendingObjectiveUpdatedNotice?: boolean;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=goal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../../shared/src/goal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,qDAAqD;AACrD,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,SAAS,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,eAAe,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,6BAA6B,CAAC,EAAE,OAAO,CAAC;CACzC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thread Goal types for @gencode/shared.
|
|
3
|
+
*
|
|
4
|
+
* Defines the cross-package contract for the lightweight thread goal system.
|
|
5
|
+
* See source/执行约束.md and artifacts/实现计划.md for design rationale.
|
|
6
|
+
*/
|
|
7
|
+
/** Maximum characters for inline objective in goal.json */
|
|
8
|
+
export const MAX_GOAL_OBJECTIVE_CHARS = 4000;
|
|
9
|
+
/** Maximum continuations per single runAgent call */
|
|
10
|
+
export const MAX_GOAL_CONTINUATIONS_PER_RUN = 3;
|
|
11
|
+
//# sourceMappingURL=goal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../../shared/src/goal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAE7C,qDAAqD;AACrD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HITL (Human-In-The-Loop) protocol types for AIMax.
|
|
3
|
+
*
|
|
4
|
+
* These types define the stable public contract shared by all packages:
|
|
5
|
+
* - @gencode/agents (produces pause requests)
|
|
6
|
+
* - @gencode/cli (emits & receives HITL events)
|
|
7
|
+
* - @gencode/web (renders HITL UI)
|
|
8
|
+
* - external systems (爱码 Max)
|
|
9
|
+
*
|
|
10
|
+
* Design principles:
|
|
11
|
+
* 1. Pause is a persisted session state, not an in-process block.
|
|
12
|
+
* 2. Resume is explicit & structured, not implicit message concatenation.
|
|
13
|
+
* 3. Every request carries an idempotency-safe requestId.
|
|
14
|
+
* 4. A single HitlRequest model covers approval / clarify / review.
|
|
15
|
+
*/
|
|
16
|
+
/** The semantic category of a HITL interaction. */
|
|
17
|
+
export type HitlKind = "approval" | "clarify" | "review";
|
|
18
|
+
/** A single selectable choice presented to the user. */
|
|
19
|
+
export type HitlChoice = {
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
};
|
|
24
|
+
/** Choice-based input (radio / checkbox / select). */
|
|
25
|
+
export type HitlChoiceInput = {
|
|
26
|
+
mode: "choice";
|
|
27
|
+
/** Allow selecting more than one choice. */
|
|
28
|
+
multiple?: boolean;
|
|
29
|
+
choices: HitlChoice[];
|
|
30
|
+
/** If true the user may also provide free-form text alongside choices. */
|
|
31
|
+
allowFreeText?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/** Free-text input (single or multi-line). */
|
|
34
|
+
export type HitlTextInput = {
|
|
35
|
+
mode: "text";
|
|
36
|
+
multiline?: boolean;
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
};
|
|
39
|
+
/** Structured form input backed by a JSON-schema-like descriptor. */
|
|
40
|
+
export type HitlFormInput = {
|
|
41
|
+
mode: "form";
|
|
42
|
+
/** JSON-Schema-like descriptor understood by the rendering layer. */
|
|
43
|
+
schema: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
/** Union of all supported input modes. */
|
|
46
|
+
export type HitlInputSchema = HitlChoiceInput | HitlTextInput | HitlFormInput;
|
|
47
|
+
/** Rich preview attachment that accompanies a review request. */
|
|
48
|
+
export type HitlPreview = {
|
|
49
|
+
mimeType: "text/plain" | "application/json" | "text/markdown";
|
|
50
|
+
content: string;
|
|
51
|
+
};
|
|
52
|
+
/** Timeout / default-action policy attached to a request. */
|
|
53
|
+
export type HitlPolicy = {
|
|
54
|
+
/** How long the external system should wait (ms) before timing out. */
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
/** What to do when the request times out without a human response. */
|
|
57
|
+
defaultOnTimeout?: "deny" | "cancel" | "continue" | "use_best_effort";
|
|
58
|
+
/** Always true — this request can be resumed later. */
|
|
59
|
+
resumable: true;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A HITL pause request produced by `@gencode/agents` and emitted through
|
|
63
|
+
* `@gencode/cli` to external systems.
|
|
64
|
+
*/
|
|
65
|
+
export type HitlRequest = {
|
|
66
|
+
/** Globally-unique request identifier (UUID). */
|
|
67
|
+
requestId: string;
|
|
68
|
+
/** The session this request belongs to. */
|
|
69
|
+
sessionId: string;
|
|
70
|
+
/** Optional correlation message id. */
|
|
71
|
+
messageId?: string;
|
|
72
|
+
/** Semantic kind of HITL interaction. */
|
|
73
|
+
kind: HitlKind;
|
|
74
|
+
/** Short human-readable title for the pause card. */
|
|
75
|
+
title: string;
|
|
76
|
+
/** Longer prompt / description explaining what the agent needs. */
|
|
77
|
+
prompt: string;
|
|
78
|
+
/** Arbitrary structured details for the rendering layer. */
|
|
79
|
+
details?: Record<string, unknown>;
|
|
80
|
+
/** Optional rich preview (e.g. draft document). */
|
|
81
|
+
preview?: HitlPreview;
|
|
82
|
+
/** Describes the expected user input shape. */
|
|
83
|
+
input: HitlInputSchema;
|
|
84
|
+
/** Timeout & default-action policy. */
|
|
85
|
+
policy: HitlPolicy;
|
|
86
|
+
/** ISO-8601 creation timestamp. */
|
|
87
|
+
createdAt: string;
|
|
88
|
+
/** ISO-8601 expiration timestamp (optional). */
|
|
89
|
+
expiresAt?: string;
|
|
90
|
+
};
|
|
91
|
+
/** The structured user response that resolves a HITL request. */
|
|
92
|
+
export type HitlResolution = {
|
|
93
|
+
/** Must match the original `HitlRequest.requestId`. */
|
|
94
|
+
requestId: string;
|
|
95
|
+
/** Must match the original session. */
|
|
96
|
+
sessionId: string;
|
|
97
|
+
/** Resolution action. */
|
|
98
|
+
action: "submit" | "cancel" | "timeout";
|
|
99
|
+
/** User-provided values (present when action === "submit"). */
|
|
100
|
+
values?: {
|
|
101
|
+
selectedChoiceIds?: string[];
|
|
102
|
+
text?: string;
|
|
103
|
+
form?: Record<string, unknown>;
|
|
104
|
+
};
|
|
105
|
+
/** Who submitted the resolution. */
|
|
106
|
+
submittedBy?: {
|
|
107
|
+
userId?: string;
|
|
108
|
+
channel?: string;
|
|
109
|
+
};
|
|
110
|
+
/** Caller-supplied idempotency key to prevent duplicate processing. */
|
|
111
|
+
idempotencyKey?: string;
|
|
112
|
+
/** ISO-8601 submission timestamp. */
|
|
113
|
+
submittedAt: string;
|
|
114
|
+
};
|
|
115
|
+
/** The checkpoint phase at which the agent was paused. */
|
|
116
|
+
export type HitlCheckpointPhase = "before_tool" | "after_tool" | "before_finalize" | "custom";
|
|
117
|
+
/** Describes the execution checkpoint so the agent can resume. */
|
|
118
|
+
export type HitlCheckpoint = {
|
|
119
|
+
/** Turn identifier for resume tracking. */
|
|
120
|
+
turnId: string;
|
|
121
|
+
/** The phase within the turn where the pause occurred. */
|
|
122
|
+
phase: HitlCheckpointPhase;
|
|
123
|
+
/** Strategy used to resume from this checkpoint. */
|
|
124
|
+
resumeStrategy: "reenter_from_checkpoint";
|
|
125
|
+
};
|
|
126
|
+
/** Tool call metadata used for precise resume of pre-tool pauses. */
|
|
127
|
+
export type HitlToolContext = {
|
|
128
|
+
toolCallId: string;
|
|
129
|
+
toolName: string;
|
|
130
|
+
toolArgs: Record<string, unknown>;
|
|
131
|
+
};
|
|
132
|
+
/** Status of a pending HITL request within a session. */
|
|
133
|
+
export type HitlStatus = "pending" | "resolved" | "expired" | "cancelled";
|
|
134
|
+
/** Persisted state written to `pending-hitl.json` in the session directory. */
|
|
135
|
+
export type PausedRunState = {
|
|
136
|
+
/** Schema version for forward-compatibility. */
|
|
137
|
+
version: 1;
|
|
138
|
+
/** Session identifier. */
|
|
139
|
+
sessionId: string;
|
|
140
|
+
/** The HITL request that caused the pause. */
|
|
141
|
+
request: HitlRequest;
|
|
142
|
+
/** Current status of the HITL request. */
|
|
143
|
+
status: HitlStatus;
|
|
144
|
+
/** Execution checkpoint for resume. */
|
|
145
|
+
checkpoint: HitlCheckpoint;
|
|
146
|
+
/** Contextual metadata. */
|
|
147
|
+
context: {
|
|
148
|
+
agentId?: string;
|
|
149
|
+
channel?: string;
|
|
150
|
+
parentSessionId?: string;
|
|
151
|
+
depth?: number;
|
|
152
|
+
};
|
|
153
|
+
/** Present when the pause happened immediately before a tool execution. */
|
|
154
|
+
toolContext?: HitlToolContext;
|
|
155
|
+
/** Present once the request has been resolved. */
|
|
156
|
+
resolution?: HitlResolution;
|
|
157
|
+
/** ISO-8601 creation timestamp. */
|
|
158
|
+
createdAt: string;
|
|
159
|
+
/** ISO-8601 last-update timestamp. */
|
|
160
|
+
updatedAt: string;
|
|
161
|
+
};
|
|
162
|
+
/** A single entry in the append-only `hitl-history.jsonl` audit log. */
|
|
163
|
+
export type HitlHistoryEntry = {
|
|
164
|
+
/** The request ID this entry relates to. */
|
|
165
|
+
requestId: string;
|
|
166
|
+
sessionId: string;
|
|
167
|
+
/** The action recorded by this entry. */
|
|
168
|
+
action: "requested" | "resolved" | "expired" | "cancelled";
|
|
169
|
+
/** Snapshot of the request (on "requested") or resolution (on "resolved"). */
|
|
170
|
+
payload: HitlRequest | HitlResolution;
|
|
171
|
+
/** ISO-8601 timestamp of this log entry. */
|
|
172
|
+
timestamp: string;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* The canonical set of tool names that are dedicated HITL interaction tools.
|
|
176
|
+
* Tools in this set are expected to produce transcript entries (assistant tool
|
|
177
|
+
* call + tool result) that form the human-interaction record. Tools NOT in
|
|
178
|
+
* this set (e.g. "exec", "apply_patch") may throw `HitlPauseSignal` for
|
|
179
|
+
* safety approvals, but their pauses should be transparent — no HITL artefacts
|
|
180
|
+
* should appear in the transcript.
|
|
181
|
+
*/
|
|
182
|
+
export declare const HITL_TOOL_NAMES: ReadonlySet<string>;
|
|
183
|
+
/** Returns true when the tool name is a dedicated HITL interaction tool. */
|
|
184
|
+
export declare function isHitlTool(toolName: string): boolean;
|
|
185
|
+
/** Type-guard: check whether a PausedRunState is still actionable. */
|
|
186
|
+
export declare function isHitlPending(state: PausedRunState): boolean;
|
|
187
|
+
/** Type-guard: check whether a PausedRunState has been resolved. */
|
|
188
|
+
export declare function isHitlResolved(state: PausedRunState): boolean;
|
|
189
|
+
/** Check whether a HITL request has expired based on its `expiresAt` field. */
|
|
190
|
+
export declare function isHitlExpired(request: HitlRequest, now?: Date): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Parses plain text only when it exactly matches a HITL UI action.
|
|
193
|
+
*
|
|
194
|
+
* This is intentionally stricter than `parseTextToResolution`: it never falls
|
|
195
|
+
* back to free text. It is used by generic message entry points to decide
|
|
196
|
+
* whether a normal user message should resolve a pending HITL request or start
|
|
197
|
+
* a new task.
|
|
198
|
+
*/
|
|
199
|
+
export declare function parseMatchedTextToResolution(text: string, request: HitlRequest): HitlResolution | null;
|
|
200
|
+
/**
|
|
201
|
+
* Parses a plain-text user response into a structured `HitlResolution`.
|
|
202
|
+
*
|
|
203
|
+
* This is designed for IM channels (快乐平安 IM, etc.) that cannot render
|
|
204
|
+
* rich UI components. The user simply replies with text like "同意", "拒绝",
|
|
205
|
+
* or free-form feedback.
|
|
206
|
+
*
|
|
207
|
+
* Matching logic:
|
|
208
|
+
* 1. If the text matches a choice label or known synonym → `action: "submit"` with that choice.
|
|
209
|
+
* 2. If the request accepts free text and no choice matched → `action: "submit"` with text value.
|
|
210
|
+
* 3. If the text looks like a cancellation keyword → `action: "cancel"`.
|
|
211
|
+
* 4. Otherwise → `action: "submit"` with text value (fallback to free text).
|
|
212
|
+
*/
|
|
213
|
+
export declare function parseTextToResolution(text: string, request: HitlRequest): HitlResolution;
|
|
214
|
+
//# sourceMappingURL=hitl.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