@ego-z/contracts 0.15.11 → 0.15.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ego-z/contracts",
3
- "version": "0.15.11",
3
+ "version": "0.15.12",
4
4
  "description": "Wire-format type contracts shared between EgoZ backend, SDK, MCP and console. Type-only — no runtime artifacts.",
5
5
  "types": "./src/index.d.ts",
6
6
  "exports": {
package/src/ask.d.ts CHANGED
@@ -211,6 +211,102 @@ export interface AskRequestBody {
211
211
  * Optional and additive: omit it and nothing changes.
212
212
  */
213
213
  contextItems?: InitContextItem[];
214
+
215
+ /**
216
+ * Output a MACHINE produced for this turn — the result of something the
217
+ * user asked to have run, not anything the user said.
218
+ *
219
+ * ── Why this needs a channel of its own ──────────────────────────────
220
+ *
221
+ * Before this field there were exactly two ways in, and both are wrong
222
+ * for a machine:
223
+ *
224
+ * - `message` persists as `role: 'user'`. A script that prints a
225
+ * customer's CSV row arrives labelled as the account owner speaking,
226
+ * and **every protection that keys off who is speaking is bypassed by
227
+ * a program printing a sentence.**
228
+ * - `contextItems` is worse, because it does not merely keep the user's
229
+ * voice — it upgrades it. Those items are rendered as things the user
230
+ * *chose deliberately* and *likely referents for anything they mention*,
231
+ * so routing `stderr` there promotes program output to something
232
+ * adjacent to instruction.
233
+ *
234
+ * `role: 'tool'` exists internally, but only EgoZ mints those and only
235
+ * from its own executions; nothing on the wire can produce one. So this
236
+ * is the channel: it is rendered to the agent as **quoted data with an
237
+ * explicit statement that a machine produced it**, never as speech and
238
+ * never as instruction.
239
+ *
240
+ * ⚠️ **You are asserting provenance when you send this.** Put here only
241
+ * what your own system produced. Anything a person typed belongs in
242
+ * `message`, whatever it is about — mislabelling user text as machine
243
+ * output is the same failure as the reverse, pointed the other way.
244
+ *
245
+ * Optional and additive: omit it and nothing changes.
246
+ */
247
+ machineOutput?: AskMachineOutput[];
248
+ }
249
+
250
+ /**
251
+ * One piece of output a machine produced for this turn.
252
+ *
253
+ * ── Truncated, never dropped — the opposite of `InitContextItem` ─────────
254
+ *
255
+ * An over-long `excerpt` on a context item is DROPPED, because a shortened
256
+ * address is a different valid address and acting on it is worse than not
257
+ * having it. Output is the other case entirely: **a clipped `stderr` is
258
+ * still evidence, and a missing one is a lie.** So this is capped by
259
+ * truncation and the truncation is declared — the agent is told the text was
260
+ * cut rather than left to conclude a command printed nothing.
261
+ *
262
+ * That asymmetry is deliberate and it is the reason these are two shapes
263
+ * rather than one generous one.
264
+ *
265
+ * ── No acceptance receipt, unlike `contextItems` ─────────────────────────
266
+ *
267
+ * `contextItemsAccepted` exists because acceptance there is lossy in ways
268
+ * the caller cannot observe — items vanish, excerpts disappear — so a
269
+ * "shared with the agent" display would otherwise be confidently wrong.
270
+ * Nothing here vanishes: an entry is either rendered or the request is
271
+ * rejected, and the one lossy case declares itself **to the reader who
272
+ * matters**, in-band, where the agent is told the text was cut. Adding a
273
+ * receipt would be a second copy of that fact, for a caller that already
274
+ * holds the full output it just sent.
275
+ */
276
+ export interface AskMachineOutput {
277
+ /**
278
+ * Your own name for whatever produced this — `"terminal"`, `"build"`.
279
+ *
280
+ * ⚠️ Free-form, and **never rendered into the prompt**, exactly like
281
+ * `InitContextItem.kind` and for the same reason: free-form caller text
282
+ * in the instruction block is an injection surface. Used for grouping
283
+ * and for your own logs.
284
+ */
285
+ source?: string;
286
+
287
+ /**
288
+ * What was run, in the user's terms — a command line, a job name.
289
+ * Rendered, because output with no statement of what produced it invites
290
+ * the agent to guess which of its own suggestions ran.
291
+ */
292
+ invocation?: string;
293
+
294
+ /**
295
+ * The text the machine produced. Required — an entry with nothing in it
296
+ * says a program ran and reported nothing, which is a claim, not an
297
+ * omission. Truncated to a server cap if long; see the header.
298
+ */
299
+ output: string;
300
+
301
+ /**
302
+ * The producer's own result status, when it has one — a process exit
303
+ * code, conventionally 0 for success.
304
+ *
305
+ * Worth sending even when `output` is empty, and especially then: it is
306
+ * the difference between *"it worked and printed nothing"* and *"it
307
+ * failed silently"*, which no amount of text can express.
308
+ */
309
+ exitCode?: number;
214
310
  }
215
311
 
216
312
  /**
@@ -113,6 +113,46 @@ export interface InitContextItem {
113
113
  * `contextItemsAccepted` on the response tells you when it happened.
114
114
  */
115
115
  excerpt?: string;
116
+
117
+ /**
118
+ * The exact string a tool needs to act on this item — a file path, a
119
+ * record id, whatever your tools take. Optional.
120
+ *
121
+ * ── Why this is not just an `excerpt` ────────────────────────────────
122
+ *
123
+ * Because the two are read differently and fail differently, and until
124
+ * this field existed they shared one. An excerpt is prose ABOUT the
125
+ * thing; an address is a HANDLE TO it, and the agent is expected to
126
+ * carry it verbatim into a tool call. Shortening prose loses a few
127
+ * words. Shortening an address produces a **different valid address** —
128
+ * so the caps differ, and so does what a consumer may do with the value.
129
+ *
130
+ * ⚠️ AN OVER-LONG ADDRESS IS DROPPED, NOT TRUNCATED, and the item still
131
+ * rides without it, exactly like `excerpt`. `addressOmitted` on the
132
+ * receipt tells you it happened — worth reading, because the agent then
133
+ * has the item's NAME and no way to act on it, which usually reads to a
134
+ * user as the agent being unable rather than under-informed.
135
+ *
136
+ * ── Send the address, or the agent will construct one ────────────────
137
+ *
138
+ * Measured, twice, on live traffic: given an item it can name but not
139
+ * address, an agent does not stop — it produces a plausible-looking
140
+ * identifier from the meaning it has. A product slug built from the
141
+ * product's name, a window key passed where a record id was wanted.
142
+ * Both fail at the tool, and the failure reads as a broken feature.
143
+ *
144
+ * So an absent address is not neutral. It is the condition under which
145
+ * an agent invents one.
146
+ *
147
+ * ── It is rendered, and that is a deliberate exception ───────────────
148
+ *
149
+ * `kind` and `id` never reach the prompt: free-form caller text in the
150
+ * instruction block is an injection surface. `address` does reach it,
151
+ * for the same reason `label` does — a handle nobody can read is not a
152
+ * handle. Send an identifier or a path, never a sentence, and never
153
+ * anything a user typed and you did not resolve.
154
+ */
155
+ address?: string;
116
156
  }
117
157
 
118
158
  /**
@@ -159,6 +199,19 @@ export interface InitContextItemAccepted {
159
199
  * detail, instead of implying it got both.
160
200
  */
161
201
  excerptOmitted?: boolean;
202
+
203
+ /**
204
+ * The item was accepted but its `address` was not — it exceeded the cap
205
+ * and was dropped rather than truncated (see `InitContextItem.address`).
206
+ *
207
+ * ⚠️ Worth surfacing more loudly than `excerptOmitted`. A lost excerpt
208
+ * costs detail; a lost address costs the agent the only way to ACT on
209
+ * the item, and what a user sees is not "it knew less about this" but
210
+ * "it couldn't do it" — or, worse, an invented identifier that fails at
211
+ * the tool. If you show a "shared with the agent" display at all, this
212
+ * is the flag that changes what the user should expect.
213
+ */
214
+ addressOmitted?: boolean;
162
215
  }
163
216
 
164
217
  /** One open window in the caller's UI. */