@oh-hai/cli 0.3.0 → 0.4.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 +65 -0
- package/README.md +17 -10
- package/dist/commands/ask.js +8 -4
- package/dist/commands/ask.js.map +1 -1
- package/dist/commands/bridge.js +1 -1
- package/dist/commands/bridge.js.map +1 -1
- package/dist/commands/messaging/build.d.ts +5 -4
- package/dist/commands/messaging/build.js +52 -47
- package/dist/commands/messaging/build.js.map +1 -1
- package/dist/commands/messaging/capability.d.ts +39 -1
- package/dist/commands/messaging/capability.js.map +1 -1
- package/dist/commands/messaging/http.d.ts +29 -9
- package/dist/commands/messaging/http.js +159 -191
- package/dist/commands/messaging/http.js.map +1 -1
- package/dist/commands/messaging/inbox-entries.d.ts +13 -6
- package/dist/commands/messaging/inbox-entries.js +100 -111
- package/dist/commands/messaging/inbox-entries.js.map +1 -1
- package/dist/commands/messaging/inbox-stream.d.ts +2 -1
- package/dist/commands/messaging/inbox-stream.js.map +1 -1
- package/dist/commands/messaging/session-drain.d.ts +11 -1
- package/dist/commands/messaging/session-drain.js +28 -10
- package/dist/commands/messaging/session-drain.js.map +1 -1
- package/dist/commands/messaging/validate.d.ts +37 -9
- package/dist/commands/messaging/validate.js +49 -19
- package/dist/commands/messaging/validate.js.map +1 -1
- package/dist/commands/messaging/wire.d.ts +22 -307
- package/dist/commands/messaging/wire.js +10 -13
- package/dist/commands/messaging/wire.js.map +1 -1
- package/dist/commands/notify.js +5 -4
- package/dist/commands/notify.js.map +1 -1
- package/dist/commands/registry.js +6 -4
- package/dist/commands/registry.js.map +1 -1
- package/dist/commands/self-test.js +27 -22
- package/dist/commands/self-test.js.map +1 -1
- package/dist/commands/task.js +8 -4
- package/dist/commands/task.js.map +1 -1
- package/dist/version.d.ts +16 -2
- package/dist/version.js +17 -2
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Actor, AgentAddress, AskMessage, Priority, RequestMode, ResponseOption, Status, TaskMessage } from "./wire.js";
|
|
1
|
+
import type { Actor, AgentAddress, AskMessage, MessageType, Priority, RequestMode, ResponseOption, Status, TaskMessage } from "./wire.js";
|
|
2
2
|
export declare const PRIORITIES: readonly Priority[];
|
|
3
3
|
export declare const REQUEST_MODES: readonly RequestMode[];
|
|
4
4
|
export declare const CALLBACK_MODES: readonly ["pull", "push"];
|
|
@@ -10,9 +10,11 @@ export type CallbackMode = (typeof CALLBACK_MODES)[number];
|
|
|
10
10
|
* `STATUSES` set in routes/messages.ts — the agent self-list includes addressed submissions, so a
|
|
11
11
|
* narrower mirror here would reject a filter on a state the caller can plainly see in that list. */
|
|
12
12
|
export declare const STATUSES: readonly Status[];
|
|
13
|
-
/** MA2H message types — the values `messages list` accepts as its `--type` filter.
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/** MA2H message types — the values `messages list` accepts as its `--type` filter. The TYPE is
|
|
14
|
+
* the layer's (`MessageType` via the wire shim); only this runtime value list is local (the core
|
|
15
|
+
* exports no runtime array of the union's members). */
|
|
16
|
+
export type { MessageType } from "./wire.js";
|
|
17
|
+
export declare const MESSAGE_TYPES: readonly MessageType[];
|
|
16
18
|
export declare function isPriority(value: string): value is Priority;
|
|
17
19
|
export declare function isStatus(value: string): value is Status;
|
|
18
20
|
export declare function isMessageType(value: string): value is MessageType;
|
|
@@ -21,11 +23,15 @@ export declare function isCallbackMode(value: string): value is CallbackMode;
|
|
|
21
23
|
/** Hub-attested resolver identity `<type>:<id>` with type ∈ {human,agent,system} (spec §9.1).
|
|
22
24
|
* Anchored end-to-end (no embedded whitespace) so a malformed `--resolver` fails loudly here. */
|
|
23
25
|
export declare function isActor(value: string): value is Actor;
|
|
24
|
-
/** Parse and validate a `--to` destination.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* the
|
|
28
|
-
*
|
|
26
|
+
/** Parse and validate a `--to` destination. The §4 address GRAMMAR is the vendored layer's
|
|
27
|
+
* `splitAddress` (the one first-`#` definition the version-stamp rule and the reference agent
|
|
28
|
+
* read); layered on top are two CLI pre-flight guards the layer leaves to products: no embedded
|
|
29
|
+
* whitespace (the Hub matches addresses exactly, so `agent:my agent` can only round-trip to a
|
|
30
|
+
* 422), and the session segment must be a HUB-MINTABLE id (`sess_` + no `#`). Throws a usage
|
|
31
|
+
* CliError on anything the grammar cannot express — notably `human:<id>` (invalid as a
|
|
32
|
+
* destination in 0.5, the human inbox is what an ABSENT `to` means) and a `#`-bearing agent id
|
|
33
|
+
* (inexpressible: its first `#` parses as the separator, and the remainder must then match
|
|
34
|
+
* `^sess_`). */
|
|
29
35
|
export declare function parseDestination(raw: string): {
|
|
30
36
|
address: AgentAddress;
|
|
31
37
|
agentId: string;
|
|
@@ -51,6 +57,28 @@ export declare function hasHumanResolver(resolvers: readonly unknown[] | undefin
|
|
|
51
57
|
* captured `human:*` can never match any real actor — the replay callers use this to note (and
|
|
52
58
|
* proceed) that only the account owner will be able to resolve the replayed ask/task. */
|
|
53
59
|
export declare function hasConcreteHumanResolver(resolvers: readonly unknown[] | undefined): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Reject an agent-form `--resolver` that is not a legal §4 address, BEFORE the envelope goes out.
|
|
62
|
+
* The grammar is the vendored layer's `splitAddress` — the SAME definition the v0.5 schema's
|
|
63
|
+
* narrowing and the version-stamp rule (`usesSessionQualifiedResolvers`) read, so this pre-flight
|
|
64
|
+
* cannot drift from what the Hub-side schema will grade.
|
|
65
|
+
*
|
|
66
|
+
* This became reachable when envelopes started declaring >= 0.5 (#712/#726: a session-qualified
|
|
67
|
+
* resolver itself lifts the stamp to 0.5). The Hub routes schema validation by declared minor, and
|
|
68
|
+
* the v0.5 message schema narrows agent-form `allowed_resolvers` from the base
|
|
69
|
+
* `^(human|agent|system):.+$` to the §4 grammar — so a value like `agent:bot#notasession`, which
|
|
70
|
+
* the v0.4 schema accepted, would be a `422 validation_error`.
|
|
71
|
+
*
|
|
72
|
+
* The tightening is CORRECT: such a string is not an address the §4 grammar can even represent, so
|
|
73
|
+
* the Hub could never have routed to it — it was accepted and then silently unmatched, because the
|
|
74
|
+
* Hub compares `allowed_resolvers` literally. Screening it here only changes WHERE the user learns
|
|
75
|
+
* that, turning an opaque server rejection into a usage error that names the grammar. Same posture
|
|
76
|
+
* as the `--to` pre-flight gate: fail locally, with something actionable.
|
|
77
|
+
*
|
|
78
|
+
* `human:` and `system:` resolvers are untouched — the v0.5 schema does not narrow them, and they
|
|
79
|
+
* are what `--resolver` is overwhelmingly used for.
|
|
80
|
+
*/
|
|
81
|
+
export declare function assertResolverGrammar(resolvers: readonly string[]): void;
|
|
54
82
|
/** Read the `--envelope` source: inline JSON, `@<path>` (local file), or `@-` (stdin, via the
|
|
55
83
|
* injected reader so tests never touch fd 0). */
|
|
56
84
|
export declare function readEnvelopeArg(raw: string, readStdin: () => Promise<string>): Promise<string>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// `@file` read in `readEnvelopeArg` (a local file); `@-` goes through the injected stdin reader
|
|
6
6
|
// so tests stay hermetic.
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
|
+
import { splitAddress } from "@oh-hai/ma2h-core/wire";
|
|
8
9
|
import { CliError } from "../../envelope.js";
|
|
9
10
|
import { isHttpUrl } from "../../url.js";
|
|
10
11
|
export const PRIORITIES = ["low", "normal", "high", "urgent"];
|
|
@@ -29,7 +30,6 @@ export const STATUSES = [
|
|
|
29
30
|
"completed",
|
|
30
31
|
"dismissed",
|
|
31
32
|
];
|
|
32
|
-
/** MA2H message types — the values `messages list` accepts as its `--type` filter. */
|
|
33
33
|
export const MESSAGE_TYPES = ["notify", "ask", "task"];
|
|
34
34
|
export function isPriority(value) {
|
|
35
35
|
return PRIORITIES.includes(value);
|
|
@@ -51,34 +51,32 @@ export function isCallbackMode(value) {
|
|
|
51
51
|
export function isActor(value) {
|
|
52
52
|
return /^(human|agent|system):[^\s]+$/.test(value);
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* before any credential or Hub call — the same loud-fail discipline `--resolver` follows. */
|
|
58
|
-
const AGENT_ADDRESS = /^agent:[^\s#]+(#sess_[^\s#]+)?$/;
|
|
59
|
-
/** Hub-minted session ids are `sess_`-prefixed (spec §16.1). Used to reject a `--session` that
|
|
60
|
-
* could never name a real session before it reaches the wire. */
|
|
54
|
+
/** Hub-minted session ids are `sess_`-prefixed with no whitespace/`#` (spec §16.1 — a `#` would
|
|
55
|
+
* collide with the §4 address separator). Used to reject a `--session` (or a `--to` session
|
|
56
|
+
* segment) that could never name a real session before it reaches the wire. */
|
|
61
57
|
const SESSION_ID = /^sess_[^\s#]+$/;
|
|
62
|
-
/** Parse and validate a `--to` destination.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* the
|
|
66
|
-
*
|
|
58
|
+
/** Parse and validate a `--to` destination. The §4 address GRAMMAR is the vendored layer's
|
|
59
|
+
* `splitAddress` (the one first-`#` definition the version-stamp rule and the reference agent
|
|
60
|
+
* read); layered on top are two CLI pre-flight guards the layer leaves to products: no embedded
|
|
61
|
+
* whitespace (the Hub matches addresses exactly, so `agent:my agent` can only round-trip to a
|
|
62
|
+
* 422), and the session segment must be a HUB-MINTABLE id (`sess_` + no `#`). Throws a usage
|
|
63
|
+
* CliError on anything the grammar cannot express — notably `human:<id>` (invalid as a
|
|
64
|
+
* destination in 0.5, the human inbox is what an ABSENT `to` means) and a `#`-bearing agent id
|
|
65
|
+
* (inexpressible: its first `#` parses as the separator, and the remainder must then match
|
|
66
|
+
* `^sess_`). */
|
|
67
67
|
export function parseDestination(raw) {
|
|
68
68
|
const value = raw.trim();
|
|
69
|
-
|
|
69
|
+
const parsed = /\s/.test(value) ? null : splitAddress(value);
|
|
70
|
+
if (parsed === null || (parsed.session !== undefined && !SESSION_ID.test(parsed.session))) {
|
|
70
71
|
const hint = value.startsWith("human:")
|
|
71
72
|
? ' — a destination is always an agent; omit --to entirely to reach the human inbox'
|
|
72
73
|
: ' (expected "agent:<id>" or "agent:<id>#sess_<session>")';
|
|
73
74
|
throw new CliError("usage", `invalid --to ${JSON.stringify(raw)}${hint}.`);
|
|
74
75
|
}
|
|
75
|
-
const hash = value.indexOf("#");
|
|
76
|
-
const principal = hash < 0 ? value : value.slice(0, hash);
|
|
77
|
-
const session = hash < 0 ? undefined : value.slice(hash + 1);
|
|
78
76
|
return {
|
|
79
77
|
address: value,
|
|
80
|
-
agentId: principal
|
|
81
|
-
...(session !== undefined ? { session } : {}),
|
|
78
|
+
agentId: parsed.principal,
|
|
79
|
+
...(parsed.session !== undefined ? { session: parsed.session } : {}),
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
82
|
/** Validate an explicitly-supplied session id (`--session` / `MA2H_SESSION_ID`). A blank or
|
|
@@ -138,6 +136,38 @@ export function hasConcreteHumanResolver(resolvers) {
|
|
|
138
136
|
return id !== "" && !id.includes("*");
|
|
139
137
|
});
|
|
140
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Reject an agent-form `--resolver` that is not a legal §4 address, BEFORE the envelope goes out.
|
|
141
|
+
* The grammar is the vendored layer's `splitAddress` — the SAME definition the v0.5 schema's
|
|
142
|
+
* narrowing and the version-stamp rule (`usesSessionQualifiedResolvers`) read, so this pre-flight
|
|
143
|
+
* cannot drift from what the Hub-side schema will grade.
|
|
144
|
+
*
|
|
145
|
+
* This became reachable when envelopes started declaring >= 0.5 (#712/#726: a session-qualified
|
|
146
|
+
* resolver itself lifts the stamp to 0.5). The Hub routes schema validation by declared minor, and
|
|
147
|
+
* the v0.5 message schema narrows agent-form `allowed_resolvers` from the base
|
|
148
|
+
* `^(human|agent|system):.+$` to the §4 grammar — so a value like `agent:bot#notasession`, which
|
|
149
|
+
* the v0.4 schema accepted, would be a `422 validation_error`.
|
|
150
|
+
*
|
|
151
|
+
* The tightening is CORRECT: such a string is not an address the §4 grammar can even represent, so
|
|
152
|
+
* the Hub could never have routed to it — it was accepted and then silently unmatched, because the
|
|
153
|
+
* Hub compares `allowed_resolvers` literally. Screening it here only changes WHERE the user learns
|
|
154
|
+
* that, turning an opaque server rejection into a usage error that names the grammar. Same posture
|
|
155
|
+
* as the `--to` pre-flight gate: fail locally, with something actionable.
|
|
156
|
+
*
|
|
157
|
+
* `human:` and `system:` resolvers are untouched — the v0.5 schema does not narrow them, and they
|
|
158
|
+
* are what `--resolver` is overwhelmingly used for.
|
|
159
|
+
*/
|
|
160
|
+
export function assertResolverGrammar(resolvers) {
|
|
161
|
+
for (const r of resolvers) {
|
|
162
|
+
if (!r.startsWith("agent:"))
|
|
163
|
+
continue;
|
|
164
|
+
if (splitAddress(r) !== null)
|
|
165
|
+
continue;
|
|
166
|
+
throw new CliError("usage", `--resolver ${JSON.stringify(r)} is not a valid agent address. The MA2H §4 grammar is ` +
|
|
167
|
+
`"agent:<id>" or "agent:<id>#sess_<session>" — an id may not contain "#", and a session ` +
|
|
168
|
+
`fragment must start with "sess_".`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
141
171
|
/** Read the `--envelope` source: inline JSON, `@<path>` (local file), or `@-` (stdin, via the
|
|
142
172
|
* injected reader so tests never touch fd 0). */
|
|
143
173
|
export async function readEnvelopeArg(raw, readStdin) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/messaging/validate.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wFAAwF;AACxF,4FAA4F;AAC5F,yFAAyF;AACzF,gGAAgG;AAChG,0BAA0B;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAA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CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,KAAgC,CAAC;AAC1C,CAAC"}
|
|
@@ -1,310 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
export type AgentAddress = `agent:${string}`;
|
|
16
|
-
export interface AgentDescriptor {
|
|
17
|
-
id: string;
|
|
18
|
-
run_id: string;
|
|
19
|
-
runtime: Runtime;
|
|
20
|
-
project?: string;
|
|
21
|
-
/** v0.5 §4.1/§16.2: the submitter's own LIVE session. Binds the Caller mailbox for a response
|
|
22
|
-
* and is client-originated lease renewal. Only legal on an envelope declaring >= 0.5. */
|
|
23
|
-
session?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface ResponseOption {
|
|
26
|
-
value: string;
|
|
27
|
-
label: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
}
|
|
30
|
-
/** Callback, discriminated by mode (push requires a url). The CLI never composes callback
|
|
31
|
-
* `auth`, so it is omitted from the local type. */
|
|
32
|
-
export type Callback = {
|
|
33
|
-
mode: "push";
|
|
34
|
-
url: string;
|
|
35
|
-
} | {
|
|
36
|
-
mode: "pull";
|
|
37
|
-
};
|
|
38
|
-
export interface AskRequest {
|
|
39
|
-
mode: RequestMode;
|
|
40
|
-
options?: ResponseOption[];
|
|
41
|
-
schema?: JsonObject;
|
|
42
|
-
allowed_resolvers?: Actor[];
|
|
43
|
-
callback?: Callback;
|
|
44
|
-
}
|
|
45
|
-
export interface TaskAction {
|
|
46
|
-
instructions: string;
|
|
47
|
-
checklist?: {
|
|
48
|
-
text: string;
|
|
49
|
-
}[];
|
|
50
|
-
allowed_resolvers?: Actor[];
|
|
51
|
-
callback?: Callback;
|
|
52
|
-
}
|
|
53
|
-
/** The wire versions this CLI composes. `0.3` is the unchanged human-inbox envelope; `0.5` is
|
|
54
|
-
* stamped ONLY on an envelope that carries v0.5 addressing vocabulary (`to` / `agent.session`) —
|
|
55
|
-
* the Hub routes schema validation by DECLARED minor and refuses either field on a pre-0.5
|
|
56
|
-
* envelope (`422 invalid_field`), so the declared version has to move with the fields. */
|
|
57
|
-
export type WireVersion = "0.3" | "0.5";
|
|
58
|
-
interface BaseEnvelope {
|
|
59
|
-
ma2h_version: WireVersion;
|
|
60
|
-
created_at: string;
|
|
61
|
-
agent: AgentDescriptor;
|
|
62
|
-
title: string;
|
|
63
|
-
body?: string;
|
|
64
|
-
priority?: Priority;
|
|
65
|
-
tags?: string[];
|
|
66
|
-
/** Agent-owned, agent-integrity-sealed resume blob (`{ sealed: "MA2HSEALv1.…" }`, via `--state`).
|
|
67
|
-
* Opaque to the Hub (MUST NOT inspect/log — spec §9.3). Sealed by `state.ts` on submit. */
|
|
68
|
-
state?: JsonObject;
|
|
69
|
-
/** v0.5 §4: an optional agent destination (`--to`). Absent = the human inbox, unchanged. Only
|
|
70
|
-
* legal on an envelope declaring >= 0.5. */
|
|
71
|
-
to?: AgentAddress;
|
|
72
|
-
}
|
|
73
|
-
export interface NotifyMessage extends BaseEnvelope {
|
|
74
|
-
type: "notify";
|
|
75
|
-
idempotency_key?: string;
|
|
76
|
-
}
|
|
77
|
-
export interface AskMessage extends BaseEnvelope {
|
|
78
|
-
type: "ask";
|
|
79
|
-
idempotency_key: string;
|
|
80
|
-
request: AskRequest;
|
|
81
|
-
}
|
|
82
|
-
export interface TaskMessage extends BaseEnvelope {
|
|
83
|
-
type: "task";
|
|
84
|
-
idempotency_key: string;
|
|
85
|
-
action: TaskAction;
|
|
86
|
-
}
|
|
87
|
-
export type A2hMessage = NotifyMessage | AskMessage | TaskMessage;
|
|
88
|
-
export type AskResolution = "answered" | "declined" | "cancelled" | "expired";
|
|
89
|
-
export type TaskResolution = "completed" | "dismissed" | "expired";
|
|
90
|
-
export type Resolution = AskResolution | TaskResolution;
|
|
91
|
-
/** The v0.5 §14.2 DELIVERY-track states, reachable only on an ADDRESSED message (`to` present):
|
|
92
|
-
* `queued` at accept, `acknowledged` once the addressee consumes the mailbox entry, `bounced`
|
|
93
|
-
* when the destination goes terminal before it does. Distinct from the §7 RESOLUTION track above —
|
|
94
|
-
* an addressed ask still reports `open` there, because `open` asserts nothing about delivery.
|
|
1
|
+
export type { JsonValue, JsonObject, Priority, Runtime, RequestMode, Actor, AgentAddress, AgentDescriptor, ResponseOption, Callback, AskRequest, TaskAction, NotifyMessage, AskMessage, TaskMessage, A2hMessage, MessageType, AskResolution, TaskResolution, Resolution, Status, ResponseDetail, A2hResponse, PresenceState, DestinationSnapshot, SubmitAck, GetMessageBody, InboundDirective, InboundDelivery, InterAgentMessage, ReceiptEntry, InboxEntryDelivery, SessionState, SessionRegisterRequest, } from "@oh-hai/ma2h-core/types";
|
|
2
|
+
import type { A2hVersion, DestinationSnapshot, Session as CoreSession } from "@oh-hai/ma2h-core/types";
|
|
3
|
+
/** The §8.7.1 entry-kind discriminator, under the CLI's historical name. The kind LIST itself is
|
|
4
|
+
* runtime data — dispatch over `ENTRY_KINDS` from `@oh-hai/ma2h-core/wire`, never a re-typed copy. */
|
|
5
|
+
export type { EntryKind as InboxEntryKind } from "@oh-hai/ma2h-core/wire";
|
|
6
|
+
/** The version an envelope DECLARES. Since #726 the stamp is the vendored layer's `wireVersionFor`
|
|
7
|
+
* rule — the LOWEST minor the envelope's features require (base `0.3`; `to`/`agent.session`/
|
|
8
|
+
* session-qualified resolvers lift to `0.5`) — so this is the full `0.x` value space, not a single
|
|
9
|
+
* literal. `MA2H_VERSION` remains the highest minor this CLI speaks (`--version --json`'s
|
|
10
|
+
* `wire_version`), a different concept on purpose (see the doc comment in the core's version.ts). */
|
|
11
|
+
export type WireVersion = A2hVersion;
|
|
12
|
+
/**
|
|
13
|
+
* The session RESOURCE as THIS Hub returns it (spec §16.1) — the vendored core's `Session` plus one
|
|
14
|
+
* PRODUCT-SIDE field the upstream type does not carry:
|
|
95
15
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
export
|
|
104
|
-
export interface ResponseDetail {
|
|
105
|
-
/** ask only: chosen option value (string) or the input object. Absent for task. */
|
|
106
|
-
value?: string | JsonObject;
|
|
107
|
-
actor: Actor;
|
|
108
|
-
resolved_at: string;
|
|
109
|
-
comment?: string;
|
|
110
|
-
}
|
|
111
|
-
export interface A2hResponse {
|
|
112
|
-
ma2h_version: "0.3";
|
|
113
|
-
in_reply_to: string;
|
|
114
|
-
resolution_id: string;
|
|
115
|
-
resolution: Resolution;
|
|
116
|
-
defaulted?: boolean;
|
|
117
|
-
response?: ResponseDetail;
|
|
118
|
-
state?: JsonObject;
|
|
119
|
-
}
|
|
120
|
-
/** Presence states a Hub may report for a destination (spec §15). `unknown` is the honest "no
|
|
121
|
-
* visibility here" — never a claim of liveness — and MUST carry no `last_seen`. */
|
|
122
|
-
export type PresenceState = "online" | "offline" | "unknown";
|
|
123
|
-
/** The destination's §15 reachability at send time, REQUIRED on every addressed-submit ack
|
|
124
|
-
* (v0.5 §8.1). Its presence doubles as the sender's version-misroute detector: a pre-0.5 Hub
|
|
125
|
-
* cannot emit this object at all, so an addressed ack WITHOUT it proves the `to` was ignored and
|
|
126
|
-
* the message filed in a human inbox instead. */
|
|
127
|
-
export interface DestinationSnapshot {
|
|
128
|
-
state: PresenceState;
|
|
129
|
-
last_seen?: string;
|
|
130
|
-
}
|
|
131
|
-
export interface SubmitAck {
|
|
132
|
-
/** The verb's OWNING-track status (spec §8.1) — `open` for any ask/task, `delivered` for a
|
|
133
|
-
* human-inbox notify, `queued` for an ADDRESSED notify. An idempotent replay returns the track's
|
|
134
|
-
* CURRENT status, which for an addressed notify may already be `acknowledged` / `bounced` /
|
|
135
|
-
* `expired` — hence the full `Status` here rather than the accept-time trio. */
|
|
136
|
-
id: string;
|
|
137
|
-
status: Status;
|
|
138
|
-
poll_url: string;
|
|
139
|
-
review_url?: string;
|
|
140
|
-
/** Present on every ADDRESSED submit ack (v0.5 §8.1); absent on the human-inbox path. */
|
|
141
|
-
destination?: DestinationSnapshot;
|
|
142
|
-
}
|
|
143
|
-
/** GET /v1/messages/:id — the stored envelope plus its lifecycle status and terminal Response. */
|
|
144
|
-
export type GetMessageBody = A2hMessage & {
|
|
145
|
-
id: string;
|
|
146
|
-
status: Status;
|
|
147
|
-
response?: A2hResponse;
|
|
148
|
-
};
|
|
149
|
-
/** One human→agent directive drained from the agent's mailbox (spec §13.1). */
|
|
150
|
-
export interface InboundDirective {
|
|
151
|
-
ma2h_version: string;
|
|
152
|
-
type: "directive";
|
|
153
|
-
id: string;
|
|
154
|
-
from: string;
|
|
155
|
-
to: string;
|
|
156
|
-
created_at: string;
|
|
157
|
-
title: string;
|
|
158
|
-
body?: string;
|
|
159
|
-
priority?: Priority;
|
|
160
|
-
tags?: string[];
|
|
161
|
-
context?: JsonValue[];
|
|
162
|
-
expires_at?: string;
|
|
163
|
-
sensitive?: boolean;
|
|
164
|
-
}
|
|
165
|
-
/** One drained directive plus its detached `MA2H-Signature` (spec §8.7 / §9.7). Forwarded verbatim
|
|
166
|
-
* so a runtime that wants defense-in-depth can verify the signature against the Hub key. */
|
|
167
|
-
export interface InboundDelivery {
|
|
168
|
-
directive: InboundDirective;
|
|
169
|
-
signature: string;
|
|
170
|
-
}
|
|
171
|
-
/** POST /v1/inbox/ack — the ids of the directives consumed by this call (spec §14; the server's
|
|
172
|
-
* `ackDirectives` returns the id array, not a count). */
|
|
173
|
-
export interface InboxAckResult {
|
|
174
|
-
acked: string[];
|
|
175
|
-
}
|
|
176
|
-
/** The delivered form of an addressed §4 envelope (spec §8.7.1). Hub-assigned `id`, Hub-attested
|
|
177
|
-
* `from` (session-qualified when the sender presented one), and `to` — the address whose principal
|
|
178
|
-
* AND session qualifier the §13.4 amendment makes the recipient check against its own identity. */
|
|
179
|
-
export interface InterAgentMessage {
|
|
180
|
-
ma2h_version: string;
|
|
181
|
-
type: "notify" | "ask" | "task";
|
|
182
|
-
id: string;
|
|
183
|
-
from: string;
|
|
184
|
-
to: string;
|
|
185
|
-
created_at: string;
|
|
186
|
-
title: string;
|
|
187
|
-
body?: string;
|
|
188
|
-
priority?: Priority;
|
|
189
|
-
tags?: string[];
|
|
190
|
-
context?: JsonValue[];
|
|
191
|
-
request?: JsonObject;
|
|
192
|
-
action?: JsonObject;
|
|
193
|
-
idempotency_key?: string;
|
|
194
|
-
}
|
|
195
|
-
/** A Hub-originated delivery-status notification to a SENDER (spec §8.7.1/§14.2); v0.5 uses it for
|
|
196
|
-
* the bounce. Its `id` (`rcpt_…`) is the §8.7.1 ack key. */
|
|
197
|
-
export interface ReceiptEntry {
|
|
198
|
-
ma2h_version: string;
|
|
199
|
-
type: "receipt";
|
|
200
|
-
id: string;
|
|
201
|
-
in_reply_to: string;
|
|
202
|
-
event: string;
|
|
203
|
-
prior: string;
|
|
204
|
-
at: string;
|
|
205
|
-
session: string;
|
|
206
|
-
to: string;
|
|
207
|
-
}
|
|
208
|
-
/** One drained (or streamed) §8.7.1 mailbox entry plus its detached `MA2H-Signature`. The kind is
|
|
209
|
-
* the discriminating KEY, not a `type` field — the wire union the Hub emits. */
|
|
210
|
-
export type InboxEntryDelivery = {
|
|
211
|
-
directive: InboundDirective;
|
|
212
|
-
signature: string;
|
|
213
|
-
} | {
|
|
214
|
-
message: InterAgentMessage;
|
|
215
|
-
signature: string;
|
|
216
|
-
} | {
|
|
217
|
-
response: A2hResponse;
|
|
218
|
-
signature: string;
|
|
219
|
-
} | {
|
|
220
|
-
receipt: ReceiptEntry;
|
|
221
|
-
signature: string;
|
|
222
|
-
};
|
|
223
|
-
/** The kinds above, as a discriminator a caller can switch on / print. */
|
|
224
|
-
export type InboxEntryKind = "directive" | "message" | "response" | "receipt";
|
|
225
|
-
/** `active → closed` (an explicit DELETE) or `active → expired` (the lease lapsed). Terminal states
|
|
226
|
-
* are immutable, and a lapsed lease READS `expired` to every reader before the reaper runs — so a
|
|
227
|
-
* client never has to model the reaper's schedule. */
|
|
228
|
-
export type SessionState = "active" | "closed" | "expired";
|
|
229
|
-
/** The session RESOURCE as the Hub returns it (spec §16.1). The id is Hub-minted, non-secret, and
|
|
230
|
-
* confers NOTHING on its own — every operation still requires the owning principal's credential,
|
|
231
|
-
* so this is safe to print, log, and pass around as an address. */
|
|
232
|
-
export interface Session {
|
|
233
|
-
id: string;
|
|
234
|
-
agent_id: string;
|
|
235
|
-
state: SessionState;
|
|
236
|
-
created_at: string;
|
|
237
|
-
/** Current lease expiry. Renewed only by client-originated activity (spec §16.2). */
|
|
238
|
-
expires_at: string;
|
|
239
|
-
last_seen?: string;
|
|
240
|
-
/** The §15.1 REACHABILITY conclusion the Hub states on the session resource (issue #654).
|
|
241
|
-
* Distinct from `state`: `state` says whether the LEASE is standing, reachability additionally
|
|
242
|
-
* requires client-originated activity inside the presence freshness window. Optional because a
|
|
243
|
-
* Hub of an earlier minor does not emit it — and because an ABSENT field must never be read as
|
|
244
|
-
* a claim either way. Read it, never re-derive it: the whole point of the Hub stating it once is
|
|
245
|
-
* that `fleet ls`, the §8.1 submit ack, the web UI and this CLI cannot drift apart. */
|
|
16
|
+
* `reachability` — the §15.1 reachability conclusion oh-hai's Hub states on the session resource
|
|
17
|
+
* (issue #654), read by `fleet ls` / `--self-test` and never re-derived client-side. It is an
|
|
18
|
+
* oh-hai extension ahead of the upstream schema, so it is layered on here (product code) rather
|
|
19
|
+
* than hand-edited into the vendored types (which would violate VENDORED.md's byte-for-byte
|
|
20
|
+
* contract). Distinct from `state`: `state` says whether the LEASE is standing; reachability
|
|
21
|
+
* additionally requires client-originated activity inside the presence freshness window.
|
|
22
|
+
*/
|
|
23
|
+
export interface Session extends CoreSession {
|
|
246
24
|
reachability?: DestinationSnapshot;
|
|
247
|
-
ttl_seconds?: number;
|
|
248
|
-
closed_at?: string;
|
|
249
|
-
/** Present and `true` ONLY when an account human closed this session — the §16.4 operator
|
|
250
|
-
* kill-switch (issue #683 §5). Absent for a lapsed lease and for the agent closing its own
|
|
251
|
-
* session, so an ABSENT field is "nobody stopped this", never "unknown".
|
|
252
|
-
*
|
|
253
|
-
* A supervised bridge branches on it: a lapse means "restart and register a fresh session", an
|
|
254
|
-
* operator close means "a human stopped you — stay down". Optional because an older Hub does not
|
|
255
|
-
* emit it, and falling back to the restart reading is the pre-#683 behaviour. */
|
|
256
|
-
closed_by_operator?: boolean;
|
|
257
|
-
run_id?: string;
|
|
258
|
-
label?: string;
|
|
259
|
-
kind?: string;
|
|
260
|
-
project?: string;
|
|
261
|
-
labels?: Record<string, string>;
|
|
262
|
-
}
|
|
263
|
-
/** `POST /v1/sessions` request body (spec §16.1). Every field is optional — the Hub owns the id,
|
|
264
|
-
* the state and the lease; `ttl_seconds` is a REQUEST it clamps two-sidedly into its bounds. */
|
|
265
|
-
export interface SessionRegisterRequest {
|
|
266
|
-
run_id?: string;
|
|
267
|
-
label?: string;
|
|
268
|
-
kind?: string;
|
|
269
|
-
project?: string;
|
|
270
|
-
labels?: Record<string, string>;
|
|
271
|
-
ttl_seconds?: number;
|
|
272
|
-
}
|
|
273
|
-
/** The subset of `GET /v1/capability` the CLI reads. Everything is optional: the document is
|
|
274
|
-
* served by Hubs of several minors, and an absent object means "this Hub does not say", never
|
|
275
|
-
* "disabled" — see `sessions.ts` on why an absent `inter_agent` in particular must not be read
|
|
276
|
-
* as a refusal. */
|
|
277
|
-
export interface HubCapability {
|
|
278
|
-
ma2h_version?: string;
|
|
279
|
-
/** The human→agent inbound leg (§8.0/§8.7). `oh-hai bridge` reads the v0.5 additions: whether the
|
|
280
|
-
* drain takes `?session=`, and — when the OPTIONAL §8.7.2 SSE binding is offered — where it lives
|
|
281
|
-
* and the ceiling on one hold. `stream_max_hold_seconds` is only the ADVERTISED ceiling: the
|
|
282
|
-
* per-hold bound arrives on the stream's own `open` event as `hold_ms` and may be shorter (it is
|
|
283
|
-
* the lesser of this and a margin before the presenting session's lease expiry), so anything
|
|
284
|
-
* scheduled against a hold uses `hold_ms`, never this. */
|
|
285
|
-
inbound?: {
|
|
286
|
-
enabled?: boolean;
|
|
287
|
-
session_param?: boolean;
|
|
288
|
-
stream_url?: string;
|
|
289
|
-
stream_max_hold_seconds?: number;
|
|
290
|
-
max_batch?: number;
|
|
291
|
-
visibility_timeout_seconds?: number;
|
|
292
|
-
};
|
|
293
|
-
/** The §9.7/§9.8 signature freshness window in seconds. `oh-hai bridge` enforces it on a drained
|
|
294
|
-
* entry's `t` before emitting anything (§13.4 step 1). */
|
|
295
|
-
replay_window_seconds?: number;
|
|
296
|
-
sessions?: {
|
|
297
|
-
enabled: boolean;
|
|
298
|
-
min_ttl_seconds?: number;
|
|
299
|
-
max_ttl_seconds?: number;
|
|
300
|
-
max_live_per_agent?: number;
|
|
301
|
-
agent_list_visibility?: boolean;
|
|
302
|
-
terminal_retention_seconds?: number;
|
|
303
|
-
};
|
|
304
|
-
inter_agent?: {
|
|
305
|
-
enabled: boolean;
|
|
306
|
-
entry_kinds?: string[];
|
|
307
|
-
sender_allowlists?: boolean;
|
|
308
|
-
};
|
|
309
25
|
}
|
|
310
|
-
export {};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
// The MA2H wire shapes the productized messaging commands compose and read
|
|
1
|
+
// The MA2H wire shapes the productized messaging commands compose and read — as a PURE RE-EXPORT
|
|
2
|
+
// SHIM over the vendored `@oh-hai/ma2h-core` (issue #726).
|
|
2
3
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// vendored AES-256-GCM seal must not be re-implemented, AGENTS.md; see `state.ts`), now that
|
|
12
|
-
// `@oh-hai/ma2h-core` is npm-publishable. These wire TYPES stay locally re-declared (types are
|
|
13
|
-
// compile-time only, erased from `dist/cli.js`); a full type re-export from the core is a separate
|
|
14
|
-
// follow-up, out of #219 scope.
|
|
4
|
+
// This module used to RE-DECLARE the wire types locally (a hand-maintained mirror of the core's
|
|
5
|
+
// `types.ts`), and the mirrors drifted exactly the way #719/#726 document: the v0.5 delivery-track
|
|
6
|
+
// states were widened here late (#649 residual) and the MCP's sibling mirror missed them entirely.
|
|
7
|
+
// Upstream #45 made the reference layer vendorable per-file, so the one definition now lives in
|
|
8
|
+
// `packages/ma2h-core` and this module keeps ONLY the module path (~19 import sites stay stable)
|
|
9
|
+
// plus the CLI-local aliases and product-side extensions listed at the bottom. No protocol shape is
|
|
10
|
+
// declared here — a new wire field lands in the vendored core (via a re-vendor pass), never in this
|
|
11
|
+
// file.
|
|
15
12
|
export {};
|
|
16
13
|
//# sourceMappingURL=wire.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../src/commands/messaging/wire.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../src/commands/messaging/wire.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,2DAA2D;AAC3D,EAAE;AACF,gGAAgG;AAChG,mGAAmG;AACnG,mGAAmG;AACnG,gGAAgG;AAChG,iGAAiG;AACjG,oGAAoG;AACpG,oGAAoG;AACpG,QAAQ"}
|
package/dist/commands/notify.js
CHANGED
|
@@ -55,10 +55,11 @@ export async function notifyCommand(ctx) {
|
|
|
55
55
|
let agentId = ctx.config.account ?? "oh-hai/notify-bot";
|
|
56
56
|
let token = ""; // reassigned on the real path below; dry-run returns before it's used
|
|
57
57
|
// Resolve an EXPLICIT session (`--session` / `MA2H_SESSION_ID`) on BOTH paths — it is local, so a
|
|
58
|
-
// preview that dropped it would misrepresent the live send
|
|
59
|
-
// `
|
|
60
|
-
//
|
|
61
|
-
// AUTO-MINT is suppressed under --dry-run (a preview
|
|
58
|
+
// preview that dropped it would misrepresent the live send: no `agent.session`. A captured
|
|
59
|
+
// `--dry-run` envelope is meant to be replayable, so it has to match what a live invocation would
|
|
60
|
+
// post. (The declared `ma2h_version` no longer diverges between the two — it is always
|
|
61
|
+
// MA2H_VERSION, #712.) Only the network-backed AUTO-MINT is suppressed under --dry-run (a preview
|
|
62
|
+
// must create no durable Hub state).
|
|
62
63
|
const attached = explicitSession(values);
|
|
63
64
|
let scope = attached !== undefined ? { ...attached, owned: false } : undefined;
|
|
64
65
|
if (!dryRun) {
|