@osstack/protocol 0.10.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/dist/approval.d.ts +102 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +52 -0
- package/dist/approval.js.map +1 -0
- package/dist/envelope.d.ts +882 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +210 -0
- package/dist/envelope.js.map +1 -0
- package/dist/event.d.ts +36 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +28 -0
- package/dist/event.js.map +1 -0
- package/dist/evidence.d.ts +51 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +34 -0
- package/dist/evidence.js.map +1 -0
- package/dist/generate.d.ts +16 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +60 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/policy.d.ts +284 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +58 -0
- package/dist/policy.js.map +1 -0
- package/dist/protocol.test.d.ts +2 -0
- package/dist/protocol.test.d.ts.map +1 -0
- package/dist/protocol.test.js +251 -0
- package/dist/protocol.test.js.map +1 -0
- package/dist/run.d.ts +34 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +25 -0
- package/dist/run.js.map +1 -0
- package/dist/schemas.test.d.ts +2 -0
- package/dist/schemas.test.d.ts.map +1 -0
- package/dist/schemas.test.js +34 -0
- package/dist/schemas.test.js.map +1 -0
- package/dist/task.d.ts +40 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +40 -0
- package/dist/task.js.map +1 -0
- package/dist/version.d.ts +11 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +18 -0
- package/dist/version.js.map +1 -0
- package/package.json +38 -0
- package/schemas/agent-command-result.schema.json +163 -0
- package/schemas/agent-command.schema.json +69 -0
- package/schemas/approval-decision.schema.json +49 -0
- package/schemas/approval-request.schema.json +38 -0
- package/schemas/event-envelope.schema.json +48 -0
- package/schemas/evidence-ref.schema.json +34 -0
- package/schemas/policy-decision.schema.json +166 -0
- package/schemas/run-summary.schema.json +50 -0
- package/schemas/task.schema.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,6EAA6E;AAC7E,eAAO,MAAM,WAAW,aAIpB,CAAC;AACL,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAQtD,eAAO,MAAM,YAAY;;;;;;;;;EAAuC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAOxD,wFAAwF;AACxF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUd,CAAC;AACZ,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,8EAA8E;AAC9E,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAUT,CAAC;AAEjB,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAE5F;AAID,eAAO,MAAM,SAAS,wJASpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAgClD,eAAO,MAAM,YAAY;;;IArBvB,qFAAqF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F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;;;QAArF,qFAAqF;;;gCA8I/C,CAAC;AAEzC,mFAAmF;AACnF,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAE3C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA9JnC,qFAAqF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8JC,CAAC"}
|
package/dist/envelope.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// Agent command envelope + result — the invoke/response contract every agent
|
|
2
|
+
// surface (Claude Code, Codex, Hermes, CI, PartnerOS) uses to call osstack
|
|
3
|
+
// application services. Implements AGENT_COMMAND_PROTOCOL_V1 exactly.
|
|
4
|
+
//
|
|
5
|
+
// ── A-007 producer-strict / consumer-lenient ──────────────────────────────
|
|
6
|
+
// `additionalProperties: false` is the PRODUCER/authoring contract: a producer
|
|
7
|
+
// MUST NOT emit fields outside its own protocol version. So the exported
|
|
8
|
+
// `AgentCommand` / `AgentCommandResult` are `.strict()` (use these to author &
|
|
9
|
+
// validate outbound values and fixtures). A CONSUMER MUST parse inbound
|
|
10
|
+
// envelopes leniently so a v1.0 consumer accepts a v1.1 message whose additions
|
|
11
|
+
// are optional — hence `parseInboundAgentCommand` / `parseInboundAgentCommandResult`
|
|
12
|
+
// use `.passthrough()`. Leniency is DEEP: A-007's "consumers MUST ignore
|
|
13
|
+
// unknown fields" is not scoped to the top level, so the lenient parsers are
|
|
14
|
+
// composed from explicit `.passthrough()` variants of every nested object
|
|
15
|
+
// (Actor, CommandScope, EvidenceRef, ApprovalRequest, NextAction, error) —
|
|
16
|
+
// a v1.1 addition like `actor.display_name` must not break a v1.0 consumer.
|
|
17
|
+
// Business rules (A-003 status<->code, A-006 retryable) are enforced in BOTH
|
|
18
|
+
// modes via superRefine; only unknown-field tolerance differs.
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
import { Actor, ActorLenient, ApprovalRequest, ApprovalRequestLenient, } from "./approval.js";
|
|
21
|
+
import { EvidenceRef, EvidenceRefLenient } from "./evidence.js";
|
|
22
|
+
import { ProtocolVersion } from "./version.js";
|
|
23
|
+
/** Dot-separated `<service>.<action>` identifier, e.g. "portfolio.daily". */
|
|
24
|
+
export const CommandName = z
|
|
25
|
+
.string()
|
|
26
|
+
.regex(/^[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$/, {
|
|
27
|
+
message: "command must be <service>.<action> (lowercase, dot-separated)",
|
|
28
|
+
});
|
|
29
|
+
/** Narrows a command to a portfolio and/or repo (A-001). */
|
|
30
|
+
const commandScopeShape = {
|
|
31
|
+
portfolio_id: z.string().min(1).optional(),
|
|
32
|
+
repo_id: z.string().min(1).optional(),
|
|
33
|
+
};
|
|
34
|
+
export const CommandScope = z.object(commandScopeShape).strict();
|
|
35
|
+
/** Consumer-lenient CommandScope (A-007 deep leniency). */
|
|
36
|
+
const CommandScopeLenient = z.object(commandScopeShape).passthrough();
|
|
37
|
+
// ── A-001 Command envelope ────────────────────────────────────────────────
|
|
38
|
+
/** Producer/authoring schema — deep-strict (A-007). Use to emit & validate outbound. */
|
|
39
|
+
export const AgentCommand = z
|
|
40
|
+
.object({
|
|
41
|
+
protocol_version: ProtocolVersion,
|
|
42
|
+
command: CommandName,
|
|
43
|
+
actor: Actor,
|
|
44
|
+
scope: CommandScope.optional(),
|
|
45
|
+
input: z.record(z.unknown()),
|
|
46
|
+
policy_profile: z.string().min(1).optional(),
|
|
47
|
+
idempotency_key: z.string().min(1).optional(),
|
|
48
|
+
})
|
|
49
|
+
.strict();
|
|
50
|
+
/** Deep-lenient mirror of AgentCommand: passthrough at every object level. */
|
|
51
|
+
const AgentCommandLenient = z
|
|
52
|
+
.object({
|
|
53
|
+
protocol_version: ProtocolVersion,
|
|
54
|
+
command: CommandName,
|
|
55
|
+
actor: ActorLenient,
|
|
56
|
+
scope: CommandScopeLenient.optional(),
|
|
57
|
+
input: z.record(z.unknown()),
|
|
58
|
+
policy_profile: z.string().min(1).optional(),
|
|
59
|
+
idempotency_key: z.string().min(1).optional(),
|
|
60
|
+
})
|
|
61
|
+
.passthrough();
|
|
62
|
+
/** Consumer parser — DEEP-lenient (A-007): unknown fields tolerated at every level. */
|
|
63
|
+
export function parseInboundAgentCommand(value) {
|
|
64
|
+
return AgentCommandLenient.parse(value);
|
|
65
|
+
}
|
|
66
|
+
// ── A-006 Error taxonomy ──────────────────────────────────────────────────
|
|
67
|
+
export const ErrorCode = z.enum([
|
|
68
|
+
"bad_request",
|
|
69
|
+
"unsupported_protocol_version",
|
|
70
|
+
"unknown_command",
|
|
71
|
+
"policy_denied",
|
|
72
|
+
"not_found",
|
|
73
|
+
"conflict",
|
|
74
|
+
"budget_exceeded",
|
|
75
|
+
"internal",
|
|
76
|
+
]);
|
|
77
|
+
/** The two codes that pair with `status: "blocked"` (A-003 / A-006). */
|
|
78
|
+
const BLOCKED_CODES = ["policy_denied", "budget_exceeded"];
|
|
79
|
+
/** The only codes allowed to be retryable — A-006: transient failures only. */
|
|
80
|
+
const RETRYABLE_CODES = ["internal", "conflict"];
|
|
81
|
+
const commandErrorShape = {
|
|
82
|
+
code: ErrorCode,
|
|
83
|
+
message: z.string().min(1),
|
|
84
|
+
/** True only for transient failures (internal, conflict) — A-006, enforced below. */
|
|
85
|
+
retryable: z.boolean(),
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* A-006: `retryable` MUST be true only for transient failures (internal,
|
|
89
|
+
* conflict). Enforced on both the strict and lenient error paths.
|
|
90
|
+
*/
|
|
91
|
+
function refineCommandError(value, ctx) {
|
|
92
|
+
if (value.retryable && !RETRYABLE_CODES.includes(value.code)) {
|
|
93
|
+
ctx.addIssue({
|
|
94
|
+
code: z.ZodIssueCode.custom,
|
|
95
|
+
path: ["retryable"],
|
|
96
|
+
message: `retryable may be true only for transient codes ${RETRYABLE_CODES.join("/")} (A-006); code is '${value.code}'`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export const CommandError = z.object(commandErrorShape).strict().superRefine(refineCommandError);
|
|
101
|
+
/** Consumer-lenient error object (A-007 deep leniency) — same A-006 rule applies. */
|
|
102
|
+
const CommandErrorLenient = z
|
|
103
|
+
.object(commandErrorShape)
|
|
104
|
+
.passthrough()
|
|
105
|
+
.superRefine(refineCommandError);
|
|
106
|
+
/** Advisory follow-up command suggestion (A-003; advisory only). */
|
|
107
|
+
const nextActionShape = {
|
|
108
|
+
command: CommandName,
|
|
109
|
+
reason: z.string().min(1),
|
|
110
|
+
};
|
|
111
|
+
export const NextAction = z.object(nextActionShape).strict();
|
|
112
|
+
/** Consumer-lenient NextAction (A-007 deep leniency). */
|
|
113
|
+
const NextActionLenient = z.object(nextActionShape).passthrough();
|
|
114
|
+
export const CommandStatus = z.enum(["ok", "needs_approval", "blocked", "error"]);
|
|
115
|
+
// ── A-003 Command result ──────────────────────────────────────────────────
|
|
116
|
+
/**
|
|
117
|
+
* A-003 status<->code mapping (JSON Schema expresses this with if/then; here it
|
|
118
|
+
* is a superRefine because JSON Schema conditionals do not round-trip through
|
|
119
|
+
* zod-to-json-schema — see schemas/ note):
|
|
120
|
+
* error => error object present (any code EXCEPT the blocked codes)
|
|
121
|
+
* blocked => error object present with code policy_denied|budget_exceeded
|
|
122
|
+
* needs_approval => required_approvals non-empty
|
|
123
|
+
* (A-006: blocked codes pair only with blocked; all other codes pair with error.)
|
|
124
|
+
*/
|
|
125
|
+
function refineAgentCommandResult(value, ctx) {
|
|
126
|
+
const isBlockedCode = value.error
|
|
127
|
+
? BLOCKED_CODES.includes(value.error.code)
|
|
128
|
+
: false;
|
|
129
|
+
if (value.status === "error") {
|
|
130
|
+
if (!value.error) {
|
|
131
|
+
ctx.addIssue({
|
|
132
|
+
code: z.ZodIssueCode.custom,
|
|
133
|
+
path: ["error"],
|
|
134
|
+
message: "status 'error' requires an error object (A-003)",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else if (isBlockedCode) {
|
|
138
|
+
ctx.addIssue({
|
|
139
|
+
code: z.ZodIssueCode.custom,
|
|
140
|
+
path: ["error", "code"],
|
|
141
|
+
message: "codes policy_denied/budget_exceeded MUST use status 'blocked', not 'error' (A-006)",
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (value.status === "blocked") {
|
|
146
|
+
if (!value.error) {
|
|
147
|
+
ctx.addIssue({
|
|
148
|
+
code: z.ZodIssueCode.custom,
|
|
149
|
+
path: ["error"],
|
|
150
|
+
message: "status 'blocked' requires an error object (A-003)",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else if (!isBlockedCode) {
|
|
154
|
+
ctx.addIssue({
|
|
155
|
+
code: z.ZodIssueCode.custom,
|
|
156
|
+
path: ["error", "code"],
|
|
157
|
+
message: "status 'blocked' requires error code policy_denied or budget_exceeded (A-003/A-006)",
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (value.status === "needs_approval") {
|
|
162
|
+
if (!value.required_approvals || value.required_approvals.length === 0) {
|
|
163
|
+
ctx.addIssue({
|
|
164
|
+
code: z.ZodIssueCode.custom,
|
|
165
|
+
path: ["required_approvals"],
|
|
166
|
+
message: "status 'needs_approval' requires a non-empty required_approvals (A-003)",
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const agentCommandResultStrictShape = {
|
|
172
|
+
protocol_version: ProtocolVersion,
|
|
173
|
+
status: CommandStatus,
|
|
174
|
+
result: z.record(z.unknown()).optional(),
|
|
175
|
+
evidence_refs: z.array(EvidenceRef).optional(),
|
|
176
|
+
required_approvals: z.array(ApprovalRequest).optional(),
|
|
177
|
+
next_actions: z.array(NextAction).optional(),
|
|
178
|
+
error: CommandError.nullable().optional(),
|
|
179
|
+
};
|
|
180
|
+
/** Producer/authoring schema — deep-strict (A-007) + A-003/A-006 enforcement. */
|
|
181
|
+
export const AgentCommandResult = z
|
|
182
|
+
.object(agentCommandResultStrictShape)
|
|
183
|
+
.strict()
|
|
184
|
+
.superRefine(refineAgentCommandResult);
|
|
185
|
+
/** Deep-lenient mirror of AgentCommandResult: passthrough at every object level. */
|
|
186
|
+
const AgentCommandResultLenient = z
|
|
187
|
+
.object({
|
|
188
|
+
protocol_version: ProtocolVersion,
|
|
189
|
+
status: CommandStatus,
|
|
190
|
+
result: z.record(z.unknown()).optional(),
|
|
191
|
+
evidence_refs: z.array(EvidenceRefLenient).optional(),
|
|
192
|
+
required_approvals: z.array(ApprovalRequestLenient).optional(),
|
|
193
|
+
next_actions: z.array(NextActionLenient).optional(),
|
|
194
|
+
error: CommandErrorLenient.nullable().optional(),
|
|
195
|
+
})
|
|
196
|
+
.passthrough()
|
|
197
|
+
.superRefine(refineAgentCommandResult);
|
|
198
|
+
/** Consumer parser — DEEP-lenient (A-007) but still enforces A-003/A-006 rules. */
|
|
199
|
+
export function parseInboundAgentCommandResult(value) {
|
|
200
|
+
return AgentCommandResultLenient.parse(value);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The strict object schema WITHOUT the top-level superRefine, exported for JSON
|
|
204
|
+
* Schema generation. (Conditional A-003/A-006 rules do not survive
|
|
205
|
+
* zod-to-json-schema; the generated schema documents the object shape and
|
|
206
|
+
* carries a $comment pointing at the spec — the superRefine + tests document
|
|
207
|
+
* the conditional rules.)
|
|
208
|
+
*/
|
|
209
|
+
export const AgentCommandResultObject = z.object(agentCommandResultStrictShape).strict();
|
|
210
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAC3E,sEAAsE;AACtE,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAC/E,wEAAwE;AACxE,gFAAgF;AAChF,qFAAqF;AACrF,yEAAyE;AACzE,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,+DAA+D;AAE/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,KAAK,EACL,YAAY,EACZ,eAAe,EACf,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC;KACzB,MAAM,EAAE;KACR,KAAK,CAAC,oCAAoC,EAAE;IAC3C,OAAO,EAAE,+DAA+D;CACzE,CAAC,CAAC;AAGL,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG;IACxB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC7B,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,CAAC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AE,YAAY,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC;AAEX,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC,6BAA6B,CAAC;KACrC,MAAM,EAAE;KACR,WAAW,CAAC,wBAAwB,CAAC,CAAC;AAGzC,oFAAoF;AACpF,MAAM,yBAAyB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,gBAAgB,EAAE,eAAe;IACjC,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE;IACrD,kBAAkB,EAAE,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,QAAQ,EAAE;IAC9D,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;IACnD,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACjD,CAAC;KACD,WAAW,EAAE;KACb,WAAW,CAAC,wBAAwB,CAAC,CAAC;AAEzC,mFAAmF;AACnF,MAAM,UAAU,8BAA8B,CAC5C,KAAc;IAEd,OAAO,yBAAyB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,MAAM,EAAE,CAAC"}
|
package/dist/event.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const EventEnvelope: z.ZodObject<{
|
|
3
|
+
/** Stable replay cursor, e.g. "run_123:42". */
|
|
4
|
+
event_id: z.ZodString;
|
|
5
|
+
seq: z.ZodNumber;
|
|
6
|
+
run_id: z.ZodString;
|
|
7
|
+
session_id: z.ZodString;
|
|
8
|
+
/** Unix seconds; float is acceptable. */
|
|
9
|
+
created_at: z.ZodNumber;
|
|
10
|
+
/** True on the last event of a run. */
|
|
11
|
+
terminal: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
/** Event family discriminator, e.g. "token.delta", "tool.done". Open in v1. */
|
|
13
|
+
type: z.ZodString;
|
|
14
|
+
/** Family-specific body. Kept open (unvalidated union) in protocol v1. */
|
|
15
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
16
|
+
}, "strict", z.ZodTypeAny, {
|
|
17
|
+
type: string;
|
|
18
|
+
run_id: string;
|
|
19
|
+
event_id: string;
|
|
20
|
+
seq: number;
|
|
21
|
+
session_id: string;
|
|
22
|
+
created_at: number;
|
|
23
|
+
terminal: boolean;
|
|
24
|
+
payload: Record<string, unknown>;
|
|
25
|
+
}, {
|
|
26
|
+
type: string;
|
|
27
|
+
run_id: string;
|
|
28
|
+
event_id: string;
|
|
29
|
+
seq: number;
|
|
30
|
+
session_id: string;
|
|
31
|
+
created_at: number;
|
|
32
|
+
payload: Record<string, unknown>;
|
|
33
|
+
terminal?: boolean | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export type EventEnvelope = z.infer<typeof EventEnvelope>;
|
|
36
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;IAEtB,+CAA+C;;;;;IAK/C,yCAAyC;;IAEzC,uCAAuC;;IAEvC,+EAA+E;;IAE/E,0EAA0E;;;;;;;;;;;;;;;;;;;;EAGnE,CAAC;AACZ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/dist/event.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// EventEnvelope — the shared event envelope for the run event log.
|
|
2
|
+
//
|
|
3
|
+
// Extraction (architecture §1): the @osstack/hermes-adapter EventEnvelopeBase
|
|
4
|
+
// (event_id, seq, run_id, session_id, created_at, terminal) plus the `type`
|
|
5
|
+
// discriminator and an OPEN `payload`. Payload unions (the 13 event families)
|
|
6
|
+
// stay out of v1 — only the envelope is genuinely shared across processes today.
|
|
7
|
+
//
|
|
8
|
+
// `created_at` is a unix-seconds number (float OK), matching hermes-adapter and
|
|
9
|
+
// core's EventRow.
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
export const EventEnvelope = z
|
|
12
|
+
.object({
|
|
13
|
+
/** Stable replay cursor, e.g. "run_123:42". */
|
|
14
|
+
event_id: z.string().min(1),
|
|
15
|
+
seq: z.number().int().nonnegative(),
|
|
16
|
+
run_id: z.string().min(1),
|
|
17
|
+
session_id: z.string().min(1),
|
|
18
|
+
/** Unix seconds; float is acceptable. */
|
|
19
|
+
created_at: z.number(),
|
|
20
|
+
/** True on the last event of a run. */
|
|
21
|
+
terminal: z.boolean().default(false),
|
|
22
|
+
/** Event family discriminator, e.g. "token.delta", "tool.done". Open in v1. */
|
|
23
|
+
type: z.string().min(1),
|
|
24
|
+
/** Family-specific body. Kept open (unvalidated union) in protocol v1. */
|
|
25
|
+
payload: z.record(z.unknown()),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,iFAAiF;AACjF,EAAE;AACF,gFAAgF;AAChF,mBAAmB;AAEnB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,MAAM,CAAC;IACN,+CAA+C;IAC/C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACnC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,yCAAyC;IACzC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,uCAAuC;IACvC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACpC,+EAA+E;IAC/E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,0EAA0E;IAC1E,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;CAC/B,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const EvidenceKind: z.ZodEnum<["report", "scorecard", "proof", "loop_state", "external"]>;
|
|
3
|
+
export type EvidenceKind = z.infer<typeof EvidenceKind>;
|
|
4
|
+
export declare const EvidenceRef: z.ZodObject<{
|
|
5
|
+
readonly kind: z.ZodEnum<["report", "scorecard", "proof", "loop_state", "external"]>;
|
|
6
|
+
/** Path or URL to the evidence artifact. */
|
|
7
|
+
readonly ref: z.ZodString;
|
|
8
|
+
/** Lowercase hex SHA-256 of the artifact, when content-addressed. */
|
|
9
|
+
readonly sha256: z.ZodOptional<z.ZodString>;
|
|
10
|
+
readonly run_id: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, "strict", z.ZodTypeAny, {
|
|
12
|
+
kind: "report" | "scorecard" | "proof" | "loop_state" | "external";
|
|
13
|
+
ref: string;
|
|
14
|
+
run_id?: string | undefined;
|
|
15
|
+
sha256?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
kind: "report" | "scorecard" | "proof" | "loop_state" | "external";
|
|
18
|
+
ref: string;
|
|
19
|
+
run_id?: string | undefined;
|
|
20
|
+
sha256?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type EvidenceRef = z.infer<typeof EvidenceRef>;
|
|
23
|
+
/**
|
|
24
|
+
* Consumer-lenient EvidenceRef (A-007 deep leniency): the lenient envelope
|
|
25
|
+
* parsers must tolerate unknown fields inside nested objects too, so a v1.1
|
|
26
|
+
* addition to an evidence item does not break a v1.0 consumer. Producers keep
|
|
27
|
+
* using the strict `EvidenceRef`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const EvidenceRefLenient: z.ZodObject<{
|
|
30
|
+
readonly kind: z.ZodEnum<["report", "scorecard", "proof", "loop_state", "external"]>;
|
|
31
|
+
/** Path or URL to the evidence artifact. */
|
|
32
|
+
readonly ref: z.ZodString;
|
|
33
|
+
/** Lowercase hex SHA-256 of the artifact, when content-addressed. */
|
|
34
|
+
readonly sha256: z.ZodOptional<z.ZodString>;
|
|
35
|
+
readonly run_id: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
37
|
+
readonly kind: z.ZodEnum<["report", "scorecard", "proof", "loop_state", "external"]>;
|
|
38
|
+
/** Path or URL to the evidence artifact. */
|
|
39
|
+
readonly ref: z.ZodString;
|
|
40
|
+
/** Lowercase hex SHA-256 of the artifact, when content-addressed. */
|
|
41
|
+
readonly sha256: z.ZodOptional<z.ZodString>;
|
|
42
|
+
readonly run_id: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
44
|
+
readonly kind: z.ZodEnum<["report", "scorecard", "proof", "loop_state", "external"]>;
|
|
45
|
+
/** Path or URL to the evidence artifact. */
|
|
46
|
+
readonly ref: z.ZodString;
|
|
47
|
+
/** Lowercase hex SHA-256 of the artifact, when content-addressed. */
|
|
48
|
+
readonly sha256: z.ZodOptional<z.ZodString>;
|
|
49
|
+
readonly run_id: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
51
|
+
//# sourceMappingURL=evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,YAAY,uEAMvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAcxD,eAAO,MAAM,WAAW;;IAVtB,4CAA4C;;IAE5C,qEAAqE;;;;;;;;;;;;;EAQT,CAAC;AAC/D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;IAnB7B,4CAA4C;;IAE5C,qEAAqE;;;;;IAFrE,4CAA4C;;IAE5C,qEAAqE;;;;;IAFrE,4CAA4C;;IAE5C,qEAAqE;;;gCAiBG,CAAC"}
|
package/dist/evidence.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// EvidenceRef — a reference to evidence a service produced/verified.
|
|
2
|
+
//
|
|
3
|
+
// Extraction (architecture §1 / Doc 15 §5.4): { kind, ref, sha256?, run_id? }.
|
|
4
|
+
// A service MUST attach evidence for anything it claims to have verified
|
|
5
|
+
// (AGENT_COMMAND_PROTOCOL_V1 A-003). `ref` is a path or URL; consumers treat
|
|
6
|
+
// markdown/prose only as human display, never as an API (ADR-001 D3).
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
export const EvidenceKind = z.enum([
|
|
9
|
+
"report",
|
|
10
|
+
"scorecard",
|
|
11
|
+
"proof",
|
|
12
|
+
"loop_state",
|
|
13
|
+
"external",
|
|
14
|
+
]);
|
|
15
|
+
const evidenceRefShape = {
|
|
16
|
+
kind: EvidenceKind,
|
|
17
|
+
/** Path or URL to the evidence artifact. */
|
|
18
|
+
ref: z.string().min(1),
|
|
19
|
+
/** Lowercase hex SHA-256 of the artifact, when content-addressed. */
|
|
20
|
+
sha256: z
|
|
21
|
+
.string()
|
|
22
|
+
.regex(/^[a-f0-9]{64}$/, { message: "sha256 must be 64 lowercase hex chars" })
|
|
23
|
+
.optional(),
|
|
24
|
+
run_id: z.string().min(1).optional(),
|
|
25
|
+
};
|
|
26
|
+
export const EvidenceRef = z.object(evidenceRefShape).strict();
|
|
27
|
+
/**
|
|
28
|
+
* Consumer-lenient EvidenceRef (A-007 deep leniency): the lenient envelope
|
|
29
|
+
* parsers must tolerate unknown fields inside nested objects too, so a v1.1
|
|
30
|
+
* addition to an evidence item does not break a v1.0 consumer. Producers keep
|
|
31
|
+
* using the strict `EvidenceRef`.
|
|
32
|
+
*/
|
|
33
|
+
export const EvidenceRefLenient = z.object(evidenceRefShape).passthrough();
|
|
34
|
+
//# sourceMappingURL=evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,6EAA6E;AAC7E,sEAAsE;AAEtE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC;IACjC,QAAQ;IACR,WAAW;IACX,OAAO;IACP,YAAY;IACZ,UAAU;CACX,CAAC,CAAC;AAGH,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,YAAY;IAClB,4CAA4C;IAC5C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,qEAAqE;IACrE,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,KAAK,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC;SAC7E,QAAQ,EAAE;IACb,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC5B,CAAC;AAEX,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,CAAC;AAG/D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ZodTypeAny } from "zod";
|
|
2
|
+
interface SchemaEntry {
|
|
3
|
+
/** File basename (without the .schema.json suffix) and schema registry key. */
|
|
4
|
+
key: string;
|
|
5
|
+
/** Human-readable title embedded in the JSON Schema. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Optional top-level $comment embedded in the generated JSON Schema. */
|
|
8
|
+
comment?: string;
|
|
9
|
+
schema: ZodTypeAny;
|
|
10
|
+
}
|
|
11
|
+
/** The 9 public protocol contracts emitted as JSON Schema. Order is stable. */
|
|
12
|
+
export declare const SCHEMA_MANIFEST: readonly SchemaEntry[];
|
|
13
|
+
/** filename -> file content for every committed schema. */
|
|
14
|
+
export declare function generateAll(): Record<string, string>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAatC,UAAU,WAAW;IACnB,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,SAAS,WAAW,EAgBjD,CAAC;AAkBF,2DAA2D;AAC3D,wBAAgB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMpD"}
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// JSON Schema generation — Zod is the source of truth; this module emits the
|
|
2
|
+
// committed schemas/*.schema.json artifacts. A single manifest is the shared
|
|
3
|
+
// source of truth for both scripts/generate-schemas.mjs (writes/checks the
|
|
4
|
+
// files) and schemas.test.ts (asserts zero drift), so regeneration is
|
|
5
|
+
// guaranteed identical from either entry point.
|
|
6
|
+
//
|
|
7
|
+
// NOTE (superRefine): the A-003 status<->code conditional rules on
|
|
8
|
+
// AgentCommandResult are enforced by a Zod superRefine, which zod-to-json-schema
|
|
9
|
+
// cannot represent. The generated agent-command-result schema therefore
|
|
10
|
+
// documents the object SHAPE only; the conditional rules live in the superRefine
|
|
11
|
+
// and the tests. This is a known, documented limitation, not a gap.
|
|
12
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
13
|
+
import { AgentCommand, AgentCommandResultObject, } from "./envelope.js";
|
|
14
|
+
import { ApprovalDecision, ApprovalRequest } from "./approval.js";
|
|
15
|
+
import { EvidenceRef } from "./evidence.js";
|
|
16
|
+
import { EventEnvelope } from "./event.js";
|
|
17
|
+
import { PolicyDecision } from "./policy.js";
|
|
18
|
+
import { RunSummary } from "./run.js";
|
|
19
|
+
import { Task } from "./task.js";
|
|
20
|
+
/** The 9 public protocol contracts emitted as JSON Schema. Order is stable. */
|
|
21
|
+
export const SCHEMA_MANIFEST = [
|
|
22
|
+
{ key: "task", title: "Osstack Protocol Task", schema: Task },
|
|
23
|
+
{ key: "run-summary", title: "Osstack Protocol Run Summary", schema: RunSummary },
|
|
24
|
+
{ key: "event-envelope", title: "Osstack Protocol Event Envelope", schema: EventEnvelope },
|
|
25
|
+
{ key: "evidence-ref", title: "Osstack Protocol Evidence Ref", schema: EvidenceRef },
|
|
26
|
+
{ key: "approval-request", title: "Osstack Protocol Approval Request", schema: ApprovalRequest },
|
|
27
|
+
{ key: "approval-decision", title: "Osstack Protocol Approval Decision", schema: ApprovalDecision },
|
|
28
|
+
{ key: "policy-decision", title: "Osstack Protocol Policy Decision", schema: PolicyDecision },
|
|
29
|
+
{ key: "agent-command", title: "Osstack Protocol Agent Command", schema: AgentCommand },
|
|
30
|
+
{
|
|
31
|
+
key: "agent-command-result",
|
|
32
|
+
title: "Osstack Protocol Agent Command Result",
|
|
33
|
+
comment: "Conditional rules (A-003 status<->code mapping, A-006 retryable constraint) are enforced by @osstack/protocol superRefine and are NOT expressible in this JSON Schema; see AGENT_COMMAND_PROTOCOL_V1.md.",
|
|
34
|
+
schema: AgentCommandResultObject,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
/** Render one schema entry to a pretty-printed JSON Schema string (trailing NL). */
|
|
38
|
+
function renderSchema(entry) {
|
|
39
|
+
const json = zodToJsonSchema(entry.schema, {
|
|
40
|
+
target: "jsonSchema7",
|
|
41
|
+
$refStrategy: "none",
|
|
42
|
+
});
|
|
43
|
+
// Stable, self-describing header fields, independent of Zod internals.
|
|
44
|
+
const withMeta = {
|
|
45
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
46
|
+
title: entry.title,
|
|
47
|
+
...(entry.comment !== undefined ? { $comment: entry.comment } : {}),
|
|
48
|
+
...json,
|
|
49
|
+
};
|
|
50
|
+
return `${JSON.stringify(withMeta, null, 2)}\n`;
|
|
51
|
+
}
|
|
52
|
+
/** filename -> file content for every committed schema. */
|
|
53
|
+
export function generateAll() {
|
|
54
|
+
const out = {};
|
|
55
|
+
for (const entry of SCHEMA_MANIFEST) {
|
|
56
|
+
out[`${entry.key}.schema.json`] = renderSchema(entry);
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,sEAAsE;AACtE,gDAAgD;AAChD,EAAE;AACF,mEAAmE;AACnE,iFAAiF;AACjF,wEAAwE;AACxE,iFAAiF;AACjF,oEAAoE;AAGpE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,YAAY,EACZ,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAYjC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAA2B;IACrD,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,IAAI,EAAE;IAC7D,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,8BAA8B,EAAE,MAAM,EAAE,UAAU,EAAE;IACjF,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,iCAAiC,EAAE,MAAM,EAAE,aAAa,EAAE;IAC1F,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,+BAA+B,EAAE,MAAM,EAAE,WAAW,EAAE;IACpF,EAAE,GAAG,EA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xD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { PROTOCOL_VERSION, ProtocolVersion } from "./version.js";
|
|
2
|
+
export { Task, TaskSource } from "./task.js";
|
|
3
|
+
export { RunOutcome, RunSummary } from "./run.js";
|
|
4
|
+
export { EventEnvelope } from "./event.js";
|
|
5
|
+
export { EvidenceKind, EvidenceRef } from "./evidence.js";
|
|
6
|
+
export { Actor, ApprovalDecision, ApprovalRequest, Risk, } from "./approval.js";
|
|
7
|
+
export { CostTier, PolicyCandidate, PolicyDecision, PolicyHandoff, PolicyOutcome, PolicyScore, } from "./policy.js";
|
|
8
|
+
export { AgentCommand, AgentCommandResult, AgentCommandResultObject, CommandError, CommandName, CommandScope, CommandStatus, ErrorCode, NextAction, parseInboundAgentCommand, parseInboundAgentCommandResult, } from "./envelope.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,QAAQ,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @osstack/protocol — stable cross-product / cross-process / cross-agent kernel
|
|
2
|
+
// contracts. Zod is the source of truth; schemas/ holds generated JSON Schema.
|
|
3
|
+
//
|
|
4
|
+
// v1 contains ONLY the shared kernel contracts (Task, Run, Event, Evidence,
|
|
5
|
+
// Approval, Policy, Agent command envelope). Loop-state internals, knowledge
|
|
6
|
+
// packs, proof-pack manifests, worktree status and evaluation-spec details are
|
|
7
|
+
// deliberately excluded until a second consumer exists (architecture §1).
|
|
8
|
+
export { PROTOCOL_VERSION, ProtocolVersion } from "./version.js";
|
|
9
|
+
export { Task, TaskSource } from "./task.js";
|
|
10
|
+
export { RunOutcome, RunSummary } from "./run.js";
|
|
11
|
+
export { EventEnvelope } from "./event.js";
|
|
12
|
+
export { EvidenceKind, EvidenceRef } from "./evidence.js";
|
|
13
|
+
export { Actor, ApprovalDecision, ApprovalRequest, Risk, } from "./approval.js";
|
|
14
|
+
export { CostTier, PolicyCandidate, PolicyDecision, PolicyHandoff, PolicyOutcome, PolicyScore, } from "./policy.js";
|
|
15
|
+
export { AgentCommand, AgentCommandResult, AgentCommandResultObject, CommandError, CommandName, CommandScope, CommandStatus, ErrorCode, NextAction, parseInboundAgentCommand, parseInboundAgentCommandResult, } from "./envelope.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,+EAA+E;AAC/E,0EAA0E;AAE1E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,QAAQ,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,eAAe,CAAC"}
|