@jigging/agent-acp 0.0.0 → 0.1.0-alpha.4
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/AGENTS.md +88 -0
- package/FLOW.contract.json +241 -0
- package/FLOW.meta.json +6 -0
- package/FLOW.ts +3 -0
- package/LICENSE +374 -0
- package/README.md +156 -0
- package/THIRD_PARTY_NOTICES +14 -0
- package/contracts/acp-public-updates.json +75 -0
- package/contracts/agent-commands.json +73 -0
- package/contracts/agent-replies.json +156 -0
- package/contracts/finite-acp/contract.json +104 -0
- package/contracts/finite-acp/requests.json +24 -0
- package/contracts/finite-acp/responses.json +102 -0
- package/dist/conversation.d.ts +8 -0
- package/dist/conversation.js +155 -0
- package/dist/flow.d.ts +4 -0
- package/dist/flow.js +3393 -0
- package/dist/transport.d.ts +56 -0
- package/dist/transport.js +209 -0
- package/dist/updates.d.ts +16 -0
- package/dist/updates.js +77 -0
- package/justfile +32 -0
- package/licenses/agent-method.LICENSE +373 -0
- package/licenses/flow.LICENSE +202 -0
- package/package.json +35 -5
- package/src/conversation.ts +192 -0
- package/src/flow.ts +495 -0
- package/src/transport.ts +242 -0
- package/src/updates.ts +76 -0
- package/test/flow.test.ts +982 -0
- package/test/pack.test.ts +76 -0
- package/test/transport.test.ts +135 -0
- package/test/updates.test.ts +94 -0
- package/tsconfig.json +17 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Ordinary finite ACP Agent
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Make finite native Agent conversations independently replaceable Flows while the host
|
|
6
|
+
retains credential, process, and dispatch authority.
|
|
7
|
+
|
|
8
|
+
## Ownership
|
|
9
|
+
|
|
10
|
+
- `src/flow.ts` owns the ordinary Agent Run method and finite ACP dialogue.
|
|
11
|
+
`src/conversation.ts` owns serial turn controls and essential replies; native
|
|
12
|
+
dispatch authority remains in the resource, not this controller.
|
|
13
|
+
- `src/transport.ts` owns the public finite-ACP text framing helper; it neither
|
|
14
|
+
authenticates nor authorizes a frame. The host validates reassembled JSON/0
|
|
15
|
+
and independently enforces its reviewed finite protocol policy.
|
|
16
|
+
- `contracts/finite-acp/` mirrors `docs/jig/spec/contracts/finite-acp/` exactly.
|
|
17
|
+
`FLOW.contract.json` and its three public channel descriptors mirror Agent Run.
|
|
18
|
+
- Package source, tests, descriptors and the bundled runtime form one artifact.
|
|
19
|
+
- `justfile` owns explicit build/test/pack recipes. Ordinary `bun pm pack`
|
|
20
|
+
retains source and bundles with versioned development dependencies; no nested
|
|
21
|
+
dependency archives or private manifest rewrites are part of distribution.
|
|
22
|
+
|
|
23
|
+
## Local Contracts
|
|
24
|
+
|
|
25
|
+
- Use only public dependency exports. No Jig imports, provider calls, process
|
|
26
|
+
launches, implicit filesystem context, or credential access.
|
|
27
|
+
- One `native` slot supplies a finite ACP resource through required direct
|
|
28
|
+
requests/responses channels. Its ready record supplies reviewed configuration;
|
|
29
|
+
the Flow has no duplicate model, provider, mode or credential settings.
|
|
30
|
+
- Metadata declares `events`, `conversation`, and `sessions` as implemented
|
|
31
|
+
Agent mechanisms. Those unconditional claims concern the method; current
|
|
32
|
+
native support, turn/retention grants and actual settlement remain separate.
|
|
33
|
+
- Jig consumers may select this declared dependency with `npm:@jigging/agent-acp`
|
|
34
|
+
in a local Binding; the Binding still grants the exact native client.
|
|
35
|
+
Contract-keyed project selection does not create that grant or choose a vendor.
|
|
36
|
+
- Reuse `@jigging/agent-method` for prompt preparation and result validation.
|
|
37
|
+
Complete ACP dialogue and resource settlement are separate requirements.
|
|
38
|
+
- Locally detected invalid ACP cancels the resource while preserving that
|
|
39
|
+
parsing error. A terminal essential-channel failure awaits the resource's
|
|
40
|
+
independent settlement without cancelling its result wait; root cancellation
|
|
41
|
+
and deadline remain binding. Channel failure never replaces an eventual
|
|
42
|
+
uncertain execution result or manufactures success.
|
|
43
|
+
Optional public updates never supply execution evidence or authority.
|
|
44
|
+
Their first loss or exhausted local relay bound discards the suffix and
|
|
45
|
+
closes the writer with `error: 'LAGGED'`; no clean EOF hides incomplete output.
|
|
46
|
+
Closed native warning notices go to console diagnostics, not answer text or
|
|
47
|
+
public events; the host strips raw metadata and rejects authoritative errors.
|
|
48
|
+
- Optional conversational mode owns bounded direct commands/replies and per-turn
|
|
49
|
+
results in `src/conversation.ts`. Native maxTurns, serial dispatch and interruption
|
|
50
|
+
settlement remain host-enforced. One-shot calls retain their simple interface.
|
|
51
|
+
Essential replies never use the lossy progress relay. Tools, MCP, binary
|
|
52
|
+
transport, implicit replacement and retries are not provided.
|
|
53
|
+
- Optional session intent is relayed to the native resource; ordinary input
|
|
54
|
+
remains null. Restoration requires the ready record's owned session ID and
|
|
55
|
+
advertised resume support, never a new-session fallback. Resume returns an
|
|
56
|
+
empty projected result; reapply every reviewed configuration before prompting.
|
|
57
|
+
The Flow validates a requested final retention receipt only after independent
|
|
58
|
+
native settlement and appends it to the final answer or conversation summary.
|
|
59
|
+
A retained receipt requires natural zero exit with no signal; a valid answer
|
|
60
|
+
can instead carry unavailable retention after confirmed cleanup.
|
|
61
|
+
Unavailable receipts require the contract's closed reason; omission or unknown
|
|
62
|
+
reasons are invalid. Storage, current authority, one-use claims and actual
|
|
63
|
+
collection remain host-owned.
|
|
64
|
+
- Prompt settlement followed by clean request EOF delegates bounded process
|
|
65
|
+
closure to its owner; the adapter does not wait for optional ACP close.
|
|
66
|
+
- `./transport` is bounded framing, not an alternative host authority filter.
|
|
67
|
+
A frame receipt does not prove dispatch, completion, or cleanup.
|
|
68
|
+
|
|
69
|
+
## Work Guidance
|
|
70
|
+
|
|
71
|
+
- Keep ordinary behavior in the package and independently enforceable policy
|
|
72
|
+
in the host. A fake peer test is not qualification of a native client.
|
|
73
|
+
|
|
74
|
+
## Verification
|
|
75
|
+
|
|
76
|
+
- `bun test packages/agent-acp/test` exercises pure framing and public RunContext
|
|
77
|
+
wiring using in-process channel/resource peers.
|
|
78
|
+
Session cases cover resume ordering, exact owned identity, readiness/capability
|
|
79
|
+
failures, final-only receipts and invalid retention facts. These deterministic
|
|
80
|
+
checks do not qualify native saved-state restoration.
|
|
81
|
+
- `just build` compiles declarations/public transport and bundles `src/flow.ts`.
|
|
82
|
+
- `just pack --destination <directory>` builds and packs explicitly. For existing
|
|
83
|
+
output use `bun pm pack --ignore-scripts --destination <directory>`.
|
|
84
|
+
- Package tests import the relocated bundle without development dependencies,
|
|
85
|
+
check source and ordinary dependency versions, and repack without workspace
|
|
86
|
+
resolution. They do not qualify a native client or host containment.
|
|
87
|
+
|
|
88
|
+
## Child DOX Index
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://flow.jig.md/schemas/invocation-contract-0.schema.json",
|
|
3
|
+
"id": "https://jig.md/contracts/agent-run",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"features": {
|
|
6
|
+
"events": "Implements the optional public-update protocol, including honest observation loss.",
|
|
7
|
+
"conversation": "Implements conversational commands, replies, turn results and final settlement; prompt allowances remain separately granted.",
|
|
8
|
+
"sessions": "Implements retain/restore requests and final receipts, including run-scoped state and honest unavailability; authority and successful retention are separate."
|
|
9
|
+
},
|
|
10
|
+
"input": {
|
|
11
|
+
"$ref": "#/$defs/RunInput"
|
|
12
|
+
},
|
|
13
|
+
"result": {
|
|
14
|
+
"oneOf": [
|
|
15
|
+
{
|
|
16
|
+
"type": "object",
|
|
17
|
+
"properties": {
|
|
18
|
+
"outcome": {
|
|
19
|
+
"const": "done"
|
|
20
|
+
},
|
|
21
|
+
"output": {
|
|
22
|
+
"$ref": "#/$defs/AgentOutput"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["outcome", "output"],
|
|
26
|
+
"additionalProperties": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"outcome": {
|
|
32
|
+
"const": "blocked"
|
|
33
|
+
},
|
|
34
|
+
"output": {
|
|
35
|
+
"$ref": "#/$defs/AgentOutput"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": ["outcome", "output"],
|
|
39
|
+
"additionalProperties": false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"outcome": {
|
|
45
|
+
"const": "limit"
|
|
46
|
+
},
|
|
47
|
+
"output": {
|
|
48
|
+
"$ref": "#/$defs/AgentOutput"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"required": ["outcome", "output"],
|
|
52
|
+
"additionalProperties": false
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"type": "object",
|
|
56
|
+
"properties": {
|
|
57
|
+
"outcome": {
|
|
58
|
+
"const": "done"
|
|
59
|
+
},
|
|
60
|
+
"output": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"session": {
|
|
64
|
+
"$ref": "#/$defs/SessionReceipt"
|
|
65
|
+
},
|
|
66
|
+
"turns": {
|
|
67
|
+
"type": "integer",
|
|
68
|
+
"minimum": 1,
|
|
69
|
+
"maximum": 8
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"required": ["turns"],
|
|
73
|
+
"additionalProperties": false
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"required": ["outcome", "output"],
|
|
77
|
+
"additionalProperties": false
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"outcomes": {
|
|
82
|
+
"blocked": "The Agent completed its bounded response but reported that the requested work is blocked.",
|
|
83
|
+
"limit": "The Agent completed its bounded response but reported an Agent limit; host deadline and cancellation remain operational failures."
|
|
84
|
+
},
|
|
85
|
+
"channels": {
|
|
86
|
+
"events": {
|
|
87
|
+
"direction": "send",
|
|
88
|
+
"required": false,
|
|
89
|
+
"contract": "./contracts/acp-public-updates.json"
|
|
90
|
+
},
|
|
91
|
+
"commands": {
|
|
92
|
+
"direction": "receive",
|
|
93
|
+
"required": false,
|
|
94
|
+
"delivery": "direct",
|
|
95
|
+
"contract": "./contracts/agent-commands.json"
|
|
96
|
+
},
|
|
97
|
+
"replies": {
|
|
98
|
+
"direction": "send",
|
|
99
|
+
"required": false,
|
|
100
|
+
"delivery": "direct",
|
|
101
|
+
"contract": "./contracts/agent-replies.json"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"$defs": {
|
|
105
|
+
"SessionRequest": {
|
|
106
|
+
"oneOf": [
|
|
107
|
+
{
|
|
108
|
+
"type": "object",
|
|
109
|
+
"properties": { "retain": { "const": true }, "lifetime": { "const": "run" } },
|
|
110
|
+
"required": ["retain"],
|
|
111
|
+
"additionalProperties": false
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"type": "object",
|
|
115
|
+
"properties": {
|
|
116
|
+
"restore": { "type": "string", "minLength": 36, "maxLength": 36 }
|
|
117
|
+
},
|
|
118
|
+
"required": ["restore"],
|
|
119
|
+
"additionalProperties": false
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"SessionReceipt": {
|
|
124
|
+
"oneOf": [
|
|
125
|
+
{
|
|
126
|
+
"type": "object",
|
|
127
|
+
"properties": {
|
|
128
|
+
"status": { "const": "retained" },
|
|
129
|
+
"reference": { "type": "string", "minLength": 36, "maxLength": 36 }
|
|
130
|
+
},
|
|
131
|
+
"required": ["status", "reference"],
|
|
132
|
+
"additionalProperties": false
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"type": "object",
|
|
136
|
+
"properties": {
|
|
137
|
+
"status": { "const": "unavailable" },
|
|
138
|
+
"reason": {
|
|
139
|
+
"enum": ["not-cleanly-closed", "missing-history", "unsupported-history", "capacity"]
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"required": ["status", "reason"],
|
|
143
|
+
"additionalProperties": false
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
"RunInput": {
|
|
148
|
+
"type": "object",
|
|
149
|
+
"properties": {
|
|
150
|
+
"instructions": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"minLength": 1,
|
|
153
|
+
"maxLength": 1048576
|
|
154
|
+
},
|
|
155
|
+
"skills": {
|
|
156
|
+
"$ref": "#/$defs/SkillContents"
|
|
157
|
+
},
|
|
158
|
+
"responseSchema": {
|
|
159
|
+
"type": "object"
|
|
160
|
+
},
|
|
161
|
+
"guidance": {
|
|
162
|
+
"type": "array",
|
|
163
|
+
"maxItems": 64,
|
|
164
|
+
"items": {
|
|
165
|
+
"type": "object",
|
|
166
|
+
"properties": {
|
|
167
|
+
"label": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"minLength": 1
|
|
170
|
+
},
|
|
171
|
+
"text": {
|
|
172
|
+
"type": "string"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"required": ["label", "text"],
|
|
176
|
+
"additionalProperties": false
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"conversation": {
|
|
180
|
+
"const": true
|
|
181
|
+
},
|
|
182
|
+
"session": {
|
|
183
|
+
"$ref": "#/$defs/SessionRequest"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"required": ["instructions"],
|
|
187
|
+
"additionalProperties": false
|
|
188
|
+
},
|
|
189
|
+
"AgentOutput": {
|
|
190
|
+
"type": "object",
|
|
191
|
+
"properties": {
|
|
192
|
+
"text": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"maxLength": 8388608
|
|
195
|
+
},
|
|
196
|
+
"structured": true,
|
|
197
|
+
"session": {
|
|
198
|
+
"$ref": "#/$defs/SessionReceipt"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"required": ["text"],
|
|
202
|
+
"additionalProperties": false
|
|
203
|
+
},
|
|
204
|
+
"SkillContents": {
|
|
205
|
+
"type": "array",
|
|
206
|
+
"maxItems": 64,
|
|
207
|
+
"items": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"properties": {
|
|
210
|
+
"name": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"minLength": 1,
|
|
213
|
+
"maxLength": 64
|
|
214
|
+
},
|
|
215
|
+
"files": {
|
|
216
|
+
"type": "array",
|
|
217
|
+
"maxItems": 1024,
|
|
218
|
+
"items": {
|
|
219
|
+
"type": "object",
|
|
220
|
+
"properties": {
|
|
221
|
+
"path": {
|
|
222
|
+
"type": "string",
|
|
223
|
+
"minLength": 1,
|
|
224
|
+
"maxLength": 4096
|
|
225
|
+
},
|
|
226
|
+
"text": {
|
|
227
|
+
"type": "string",
|
|
228
|
+
"maxLength": 1048576
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"required": ["path", "text"],
|
|
232
|
+
"additionalProperties": false
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"required": ["name", "files"],
|
|
237
|
+
"additionalProperties": false
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
package/FLOW.meta.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-acp",
|
|
3
|
+
"supports": ["events", "conversation", "sessions"],
|
|
4
|
+
"description": "Prepare one Agent task, exchange a finite ACP turn through an authorized resource, and check its result.",
|
|
5
|
+
"uses": { "native": { "contract": "./contracts/finite-acp/contract.json" } }
|
|
6
|
+
}
|
package/FLOW.ts
ADDED