@multiagency/sdk 0.3.1
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/CHANGES.md +21 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/THIRD-PARTY-NOTICES +127 -0
- package/bin/release-server.d.mts +29 -0
- package/bin/release-server.mjs +143 -0
- package/dist/compensation-contract.d.ts +370 -0
- package/dist/compensation-contract.js +51 -0
- package/dist/contract/agent-connection.d.ts +86 -0
- package/dist/contract/agent-connection.js +36 -0
- package/dist/contract/app-access.d.ts +141 -0
- package/dist/contract/app-access.js +57 -0
- package/dist/contract/app-client.d.ts +140 -0
- package/dist/contract/app-client.js +61 -0
- package/dist/contract/app-consent.d.ts +68 -0
- package/dist/contract/app-consent.js +91 -0
- package/dist/contract/assets.d.ts +6 -0
- package/dist/contract/assets.js +6 -0
- package/dist/contract/client.d.ts +347 -0
- package/dist/contract/client.js +81 -0
- package/dist/contract/gateway.d.ts +74 -0
- package/dist/contract/gateway.js +47 -0
- package/dist/contract/index.d.ts +26 -0
- package/dist/contract/index.js +25 -0
- package/dist/contract/inputs.d.ts +230 -0
- package/dist/contract/inputs.js +99 -0
- package/dist/contract/intents-account.d.ts +5 -0
- package/dist/contract/intents-account.js +8 -0
- package/dist/contract/orpc-client.js +2037 -0
- package/dist/contract/owner-capabilities.d.ts +81 -0
- package/dist/contract/owner-capabilities.js +33 -0
- package/dist/contract/owner-client.d.ts +99 -0
- package/dist/contract/owner-client.js +146 -0
- package/dist/contract/owner-contract.d.ts +1156 -0
- package/dist/contract/owner-contract.js +37 -0
- package/dist/contract/owner-inputs.d.ts +166 -0
- package/dist/contract/owner-inputs.js +1 -0
- package/dist/contract/owner-outputs.d.ts +5749 -0
- package/dist/contract/owner-outputs.js +751 -0
- package/dist/contract/package-version.d.ts +5 -0
- package/dist/contract/package-version.js +2 -0
- package/dist/contract/payee-entry.d.ts +10 -0
- package/dist/contract/payee-entry.js +10 -0
- package/dist/contract/payee.d.ts +326 -0
- package/dist/contract/payee.js +32 -0
- package/dist/contract/permissions.d.ts +20 -0
- package/dist/contract/permissions.js +64 -0
- package/dist/contract/proposals.d.ts +178 -0
- package/dist/contract/proposals.js +27 -0
- package/dist/contract/run-log-schema.d.ts +888 -0
- package/dist/contract/run-log-schema.js +150 -0
- package/dist/contract/run-progress-schema.d.ts +104 -0
- package/dist/contract/run-progress-schema.js +20 -0
- package/dist/payee-contract.d.ts +9 -0
- package/dist/payee-contract.js +15 -0
- package/package.json +58 -0
- package/provenance.json +61 -0
- package/schemas/agentConnection.json +76 -0
- package/schemas/agentConnectionIssue.json +22 -0
- package/schemas/agentConnectionList.json +88 -0
- package/schemas/agentConnectionStarted.json +90 -0
- package/schemas/compensationSend.json +40 -0
- package/schemas/errorBody.json +16 -0
- package/schemas/fileResult.json +67 -0
- package/schemas/invoicesView.json +130 -0
- package/schemas/ownerCompensationView.json +556 -0
- package/schemas/payeeCompensationView.json +546 -0
- package/schemas/payeeWorkOrderRequest.json +31 -0
- package/schemas/publicWorkOrder.json +94 -0
- package/schemas/reportCommand.json +82 -0
- package/schemas/requestRecord.json +149 -0
- package/schemas/session.json +20 -0
- package/schemas/workOrderList.json +43 -0
- package/schemas/workOrderRequestResult.json +20 -0
- package/skills/app-server/SKILL.md +190 -0
- package/skills/getting-started/SKILL.md +90 -0
- package/skills/owner-workflows/SKILL.md +157 -0
- package/skills/payee-workflows/SKILL.md +200 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { EventSchemas } from "@ag-ui/core/schemas";
|
|
2
|
+
import { PROTOCOL_VERSION } from "@ag-ui/core";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { StepNameSchema, SubmissionSchema } from "./run-progress-schema.js";
|
|
5
|
+
/** Private, observational format. No field in this module may authorize an operation. */
|
|
6
|
+
export const AGUI_VERSION = "1.0.3";
|
|
7
|
+
/** Earlier package versions whose recordings stay readable: their events still parse with the current schemas. */
|
|
8
|
+
const READABLE_AGUI_VERSIONS = ["1.0.2", AGUI_VERSION];
|
|
9
|
+
export const AGUI_PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
10
|
+
export const MAX_RECORDING_BYTES = 2_000_000;
|
|
11
|
+
export const text = z.string().max(4096);
|
|
12
|
+
export const id = z.string().min(1).max(200);
|
|
13
|
+
export const iso = z.iso.datetime({ offset: true });
|
|
14
|
+
const units = z.string().regex(/^\d+$/).max(200);
|
|
15
|
+
const number = z.number().finite();
|
|
16
|
+
export const GapSchema = z.strictObject({ code: id, line: z.number().int().positive().optional(), ref: text.optional() });
|
|
17
|
+
/** A safe projection of one physical journal line, not the folded operation or its raw request. */
|
|
18
|
+
export const JournalRecordSchema = z.strictObject({
|
|
19
|
+
line: z.number().int().positive(), recordedAt: iso.nullable(), idempotencyKey: id,
|
|
20
|
+
type: z.enum(["request", "submission-claim", "status", "refusal"]),
|
|
21
|
+
method: z.enum(["swap", "transfer", "shield", "unshield"]).optional(),
|
|
22
|
+
planId: id.optional(), correlationId: id.optional(), status: id.optional(), refusal: id.optional(),
|
|
23
|
+
});
|
|
24
|
+
export const JournalHistorySchema = z.strictObject({ agentId: id, records: z.array(JournalRecordSchema).max(20_000), gaps: z.array(GapSchema).max(20_001) });
|
|
25
|
+
export const StartSchema = z.object({
|
|
26
|
+
progressVersion: z.literal(1).optional(),
|
|
27
|
+
id, agentId: id, at: iso, trigger: z.enum(["schedule", "operator"]),
|
|
28
|
+
schedule: z.object({ on: z.boolean(), everyMin: number, maxUsd: number, lastRun: iso.nullable() }),
|
|
29
|
+
build: z.object({ deployment: text.nullable(), source: text, lockfile: text.nullable(), packageJson: text.nullable() }),
|
|
30
|
+
policy: z.object({ revision: number.nullable(), digest: text.nullable(), status: text }), strategy: text,
|
|
31
|
+
grant: z.object({ id, label: text, expiresAt: iso }).nullable(),
|
|
32
|
+
});
|
|
33
|
+
const window = z.object({ limit_usd: z.string().max(200).nullable(), remaining_usd: z.string().max(200).nullable() });
|
|
34
|
+
export const BudgetSchema = z.object({ daily: window, weekly: window, monthly: window });
|
|
35
|
+
export const SeenSchema = z.union([
|
|
36
|
+
z.object({ error: text }),
|
|
37
|
+
z.object({ at: iso, book: z.array(z.object({ asset: id, public: units, confidential: units, usd: number })).max(500),
|
|
38
|
+
weightsBps: z.record(id, number), targetBps: z.record(id, number), driftBps: number, budget: BudgetSchema.nullable(), unresolved: z.number().int().nonnegative() }),
|
|
39
|
+
]);
|
|
40
|
+
export const PlanSchema = z.object({ id, usd: number, legs: z.array(z.object({
|
|
41
|
+
from: id, to: id, amount: units, amountOut: units, minAmountOut: units, costBps: number,
|
|
42
|
+
})).max(500) });
|
|
43
|
+
export const DisplaySchema = z.object({ asOf: iso, assets: z.array(z.object({ asset: id, symbol: z.string().min(1).max(80), decimals: z.number().int().min(0).max(255) })).max(500) });
|
|
44
|
+
const result = z.strictObject({ outcome: text, refusal: text.nullable(), rejected: z.array(text).max(500) });
|
|
45
|
+
/** The current tick recorder's explicit failure marker; provider operation statuses are independent. */
|
|
46
|
+
export const recordedTickFailed = (value) => value.refusal === null && value.outcome.startsWith("Failed: ");
|
|
47
|
+
const provenance = z.strictObject({
|
|
48
|
+
eventId: text, source: z.literal("tick"), recordRef: text, recordedAt: iso.nullable(),
|
|
49
|
+
observedAt: iso.nullable(), timing: z.enum(["recorded", "observed", "unknown"]),
|
|
50
|
+
});
|
|
51
|
+
const operation = {
|
|
52
|
+
index: z.number().int().nonnegative(), correlationId: z.string().max(200), status: id, failureCode: text.nullable(),
|
|
53
|
+
historySource: z.literal("journal"),
|
|
54
|
+
history: z.array(JournalRecordSchema).max(20_000), untimedHistory: z.array(JournalRecordSchema).max(20_000),
|
|
55
|
+
};
|
|
56
|
+
const payload = z.discriminatedUnion("stage", [
|
|
57
|
+
SubmissionSchema,
|
|
58
|
+
z.strictObject({ stage: z.literal("before"), observation: SeenSchema }),
|
|
59
|
+
z.strictObject({ stage: z.literal("shield"), asset: id, ...operation }),
|
|
60
|
+
z.strictObject({ stage: z.literal("plan"), plan: PlanSchema.nullable(), summary: text, rejected: z.array(text).max(500) }),
|
|
61
|
+
z.strictObject({ stage: z.literal("send"), ...operation }),
|
|
62
|
+
z.strictObject({ stage: z.literal("after"), observation: SeenSchema }),
|
|
63
|
+
]);
|
|
64
|
+
const base = { timestamp: z.number().finite().optional(), metadata: provenance };
|
|
65
|
+
const EventSchema = z.discriminatedUnion("type", [
|
|
66
|
+
z.strictObject({ type: z.literal("STEP_STARTED"), stepName: StepNameSchema, ...base }),
|
|
67
|
+
z.strictObject({ type: z.literal("STEP_FINISHED"), stepName: StepNameSchema, ...base }),
|
|
68
|
+
z.strictObject({ type: z.literal("RUN_STARTED"), threadId: text, runId: id, protocolVersion: z.literal(AGUI_PROTOCOL_VERSION).optional(), ...base }),
|
|
69
|
+
z.strictObject({ type: z.literal("CUSTOM"), name: z.literal("treasury.observation"), value: payload, ...base }),
|
|
70
|
+
z.strictObject({ type: z.literal("RUN_FINISHED"), threadId: text, runId: id, result, ...base }),
|
|
71
|
+
z.strictObject({ type: z.literal("RUN_ERROR"), message: text, code: z.enum(["tick_failed", "progress_incomplete"]),
|
|
72
|
+
timestamp: base.timestamp, metadata: provenance.extend({ tickResult: result }) }),
|
|
73
|
+
]).superRefine((event, ctx) => {
|
|
74
|
+
if (!EventSchemas.safeParse(event).success)
|
|
75
|
+
ctx.addIssue({ code: "custom", message: `Invalid AG-UI ${AGUI_VERSION} event` });
|
|
76
|
+
});
|
|
77
|
+
export const RecordingSchema = z.strictObject({
|
|
78
|
+
schemaVersion: z.union([z.literal(1), z.literal(2), z.literal(3)]), aguiVersion: z.enum(READABLE_AGUI_VERSIONS), agentId: id, tickId: id, exportedAt: iso,
|
|
79
|
+
completion: z.enum(["recorded-end", "no-recorded-end"]), context: StartSchema, display: DisplaySchema,
|
|
80
|
+
gaps: z.array(GapSchema).max(25_000), events: z.array(EventSchema).min(1).max(2000),
|
|
81
|
+
laterObservations: z.array(z.strictObject({ correlationId: id, source: z.literal("journal"), record: JournalRecordSchema })).max(20_000),
|
|
82
|
+
}).superRefine((recording, ctx) => {
|
|
83
|
+
const fail = (message) => ctx.addIssue({ code: "custom", message });
|
|
84
|
+
if (recording.agentId !== recording.context.agentId || recording.tickId !== recording.context.id)
|
|
85
|
+
fail("Recording identity mismatch");
|
|
86
|
+
const events = recording.events;
|
|
87
|
+
if (events[0]?.type !== "RUN_STARTED")
|
|
88
|
+
fail("Missing run start");
|
|
89
|
+
const current = recording.schemaVersion === 3;
|
|
90
|
+
// v1/v2 are retained archives, not retroactively certified protocol streams.
|
|
91
|
+
if (current && events[0]?.type === "RUN_STARTED" && events[0].protocolVersion !== AGUI_PROTOCOL_VERSION)
|
|
92
|
+
fail("Missing protocol version");
|
|
93
|
+
if (!current && events.some(event => event.type === "RUN_ERROR" || (event.type === "RUN_STARTED" && event.protocolVersion !== undefined)))
|
|
94
|
+
fail("Lifecycle fields require recording version 3");
|
|
95
|
+
const isProgress = (event) => event.type === "STEP_STARTED" || event.type === "STEP_FINISHED" || (event.type === "CUSTOM" && event.value.stage === "submission");
|
|
96
|
+
if (recording.schemaVersion === 1 && events.some(isProgress))
|
|
97
|
+
fail("Progress requires recording version 2");
|
|
98
|
+
if (recording.completion === "no-recorded-end" && (events.slice(1).some(e => !isProgress(e)) || recording.laterObservations.length))
|
|
99
|
+
fail("Incomplete tick has inferred events");
|
|
100
|
+
const active = new Set(), finished = new Set();
|
|
101
|
+
let progressAt = Date.parse(recording.context.at);
|
|
102
|
+
for (const event of events.filter(isProgress)) {
|
|
103
|
+
if (event.metadata.timing !== "recorded" || event.timestamp === undefined || event.timestamp < progressAt || event.timestamp > Date.parse(recording.exportedAt))
|
|
104
|
+
fail("Invalid progress timing");
|
|
105
|
+
progressAt = event.timestamp ?? progressAt;
|
|
106
|
+
if (event.type === "STEP_STARTED") {
|
|
107
|
+
if (active.has(event.stepName) || finished.has(event.stepName))
|
|
108
|
+
fail("Repeated stage");
|
|
109
|
+
active.add(event.stepName);
|
|
110
|
+
}
|
|
111
|
+
else if (event.type === "STEP_FINISHED") {
|
|
112
|
+
if (!active.delete(event.stepName))
|
|
113
|
+
fail("Stage never started");
|
|
114
|
+
finished.add(event.stepName);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const end = events.at(-1);
|
|
118
|
+
const terminal = end?.type === "RUN_FINISHED" || end?.type === "RUN_ERROR";
|
|
119
|
+
if (recording.completion === "recorded-end" && !terminal)
|
|
120
|
+
fail("Missing recorded end");
|
|
121
|
+
if (terminal && events.filter(isProgress).some(event => event.timestamp > end.timestamp))
|
|
122
|
+
fail("Progress recorded after run end");
|
|
123
|
+
if (current && end?.type === "RUN_FINISHED") {
|
|
124
|
+
if (active.size)
|
|
125
|
+
fail("Run finished with open stages");
|
|
126
|
+
if (recordedTickFailed(end.result))
|
|
127
|
+
fail("Recorded failure requires run error");
|
|
128
|
+
}
|
|
129
|
+
if (end?.type === "RUN_ERROR") {
|
|
130
|
+
if (end.code === "tick_failed" && !recordedTickFailed(end.metadata.tickResult))
|
|
131
|
+
fail("Run error lacks recorded failure");
|
|
132
|
+
if (end.code === "progress_incomplete" && !active.size)
|
|
133
|
+
fail("Progress error has no open stage");
|
|
134
|
+
}
|
|
135
|
+
const ids = new Set();
|
|
136
|
+
for (const [i, event] of events.entries()) {
|
|
137
|
+
if (ids.has(event.metadata.eventId))
|
|
138
|
+
fail("Duplicate event identity");
|
|
139
|
+
ids.add(event.metadata.eventId);
|
|
140
|
+
if (event.type === "RUN_STARTED" && i !== 0)
|
|
141
|
+
fail("Unexpected run start");
|
|
142
|
+
if ((event.type === "RUN_FINISHED" || event.type === "RUN_ERROR") && i !== events.length - 1)
|
|
143
|
+
fail("Unexpected run end");
|
|
144
|
+
if ((event.type === "RUN_STARTED" || event.type === "RUN_FINISHED") && (event.runId !== recording.tickId || event.threadId !== `tick:${recording.agentId}:${recording.tickId}`))
|
|
145
|
+
fail("Event identity mismatch");
|
|
146
|
+
const time = event.metadata.timing === "recorded" ? event.metadata.recordedAt : event.metadata.observedAt;
|
|
147
|
+
if (event.metadata.timing === "unknown" ? event.timestamp !== undefined : !time || event.timestamp !== Date.parse(time))
|
|
148
|
+
fail("Event timing mismatch");
|
|
149
|
+
}
|
|
150
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const STAGE_LABEL: {
|
|
3
|
+
readonly "balances-before": "Checking balances";
|
|
4
|
+
readonly recovery: "Checking unresolved operations";
|
|
5
|
+
readonly sweep: "Checking and shielding public balances";
|
|
6
|
+
readonly planning: "Planning and quoting swaps";
|
|
7
|
+
readonly execution: "Checking and executing the plan";
|
|
8
|
+
readonly "balances-after": "Checking balances after the run";
|
|
9
|
+
};
|
|
10
|
+
export declare const StepNameSchema: z.ZodEnum<{
|
|
11
|
+
"balances-after": "balances-after";
|
|
12
|
+
"balances-before": "balances-before";
|
|
13
|
+
execution: "execution";
|
|
14
|
+
planning: "planning";
|
|
15
|
+
recovery: "recovery";
|
|
16
|
+
sweep: "sweep";
|
|
17
|
+
}>;
|
|
18
|
+
export declare const SubmissionSchema: z.ZodObject<{
|
|
19
|
+
stage: z.ZodLiteral<"submission">;
|
|
20
|
+
method: z.ZodEnum<{
|
|
21
|
+
shield: "shield";
|
|
22
|
+
swap: "swap";
|
|
23
|
+
transfer: "transfer";
|
|
24
|
+
unshield: "unshield";
|
|
25
|
+
}>;
|
|
26
|
+
correlationId: z.ZodString;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
export declare const ProgressEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"STEP_STARTED">;
|
|
30
|
+
stepName: z.ZodEnum<{
|
|
31
|
+
"balances-after": "balances-after";
|
|
32
|
+
"balances-before": "balances-before";
|
|
33
|
+
execution: "execution";
|
|
34
|
+
planning: "planning";
|
|
35
|
+
recovery: "recovery";
|
|
36
|
+
sweep: "sweep";
|
|
37
|
+
}>;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
type: z.ZodLiteral<"STEP_FINISHED">;
|
|
40
|
+
stepName: z.ZodEnum<{
|
|
41
|
+
"balances-after": "balances-after";
|
|
42
|
+
"balances-before": "balances-before";
|
|
43
|
+
execution: "execution";
|
|
44
|
+
planning: "planning";
|
|
45
|
+
recovery: "recovery";
|
|
46
|
+
sweep: "sweep";
|
|
47
|
+
}>;
|
|
48
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
49
|
+
type: z.ZodLiteral<"CUSTOM">;
|
|
50
|
+
name: z.ZodLiteral<"treasury.observation">;
|
|
51
|
+
value: z.ZodObject<{
|
|
52
|
+
stage: z.ZodLiteral<"submission">;
|
|
53
|
+
method: z.ZodEnum<{
|
|
54
|
+
shield: "shield";
|
|
55
|
+
swap: "swap";
|
|
56
|
+
transfer: "transfer";
|
|
57
|
+
unshield: "unshield";
|
|
58
|
+
}>;
|
|
59
|
+
correlationId: z.ZodString;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
}, z.core.$strict>], "type">;
|
|
62
|
+
export declare const ProgressRecordSchema: z.ZodObject<{
|
|
63
|
+
version: z.ZodLiteral<1>;
|
|
64
|
+
agentId: z.ZodString;
|
|
65
|
+
tickId: z.ZodString;
|
|
66
|
+
sequence: z.ZodNumber;
|
|
67
|
+
at: z.ZodISODateTime;
|
|
68
|
+
event: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
69
|
+
type: z.ZodLiteral<"STEP_STARTED">;
|
|
70
|
+
stepName: z.ZodEnum<{
|
|
71
|
+
"balances-after": "balances-after";
|
|
72
|
+
"balances-before": "balances-before";
|
|
73
|
+
execution: "execution";
|
|
74
|
+
planning: "planning";
|
|
75
|
+
recovery: "recovery";
|
|
76
|
+
sweep: "sweep";
|
|
77
|
+
}>;
|
|
78
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"STEP_FINISHED">;
|
|
80
|
+
stepName: z.ZodEnum<{
|
|
81
|
+
"balances-after": "balances-after";
|
|
82
|
+
"balances-before": "balances-before";
|
|
83
|
+
execution: "execution";
|
|
84
|
+
planning: "planning";
|
|
85
|
+
recovery: "recovery";
|
|
86
|
+
sweep: "sweep";
|
|
87
|
+
}>;
|
|
88
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"CUSTOM">;
|
|
90
|
+
name: z.ZodLiteral<"treasury.observation">;
|
|
91
|
+
value: z.ZodObject<{
|
|
92
|
+
stage: z.ZodLiteral<"submission">;
|
|
93
|
+
method: z.ZodEnum<{
|
|
94
|
+
shield: "shield";
|
|
95
|
+
swap: "swap";
|
|
96
|
+
transfer: "transfer";
|
|
97
|
+
unshield: "unshield";
|
|
98
|
+
}>;
|
|
99
|
+
correlationId: z.ZodString;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
}, z.core.$strict>], "type">;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
export type ProgressEvent = z.infer<typeof ProgressEventSchema>;
|
|
104
|
+
export type ProgressRecord = z.infer<typeof ProgressRecordSchema>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const STAGE_LABEL = {
|
|
3
|
+
"balances-before": "Checking balances",
|
|
4
|
+
recovery: "Checking unresolved operations",
|
|
5
|
+
sweep: "Checking and shielding public balances",
|
|
6
|
+
planning: "Planning and quoting swaps",
|
|
7
|
+
execution: "Checking and executing the plan",
|
|
8
|
+
"balances-after": "Checking balances after the run",
|
|
9
|
+
};
|
|
10
|
+
export const StepNameSchema = z.enum(Object.keys(STAGE_LABEL));
|
|
11
|
+
export const SubmissionSchema = z.strictObject({ stage: z.literal("submission"), method: z.enum(["swap", "shield", "transfer", "unshield"]), correlationId: z.string().min(1).max(200) });
|
|
12
|
+
export const ProgressEventSchema = z.discriminatedUnion("type", [
|
|
13
|
+
z.strictObject({ type: z.literal("STEP_STARTED"), stepName: StepNameSchema }),
|
|
14
|
+
z.strictObject({ type: z.literal("STEP_FINISHED"), stepName: StepNameSchema }),
|
|
15
|
+
z.strictObject({ type: z.literal("CUSTOM"), name: z.literal("treasury.observation"), value: SubmissionSchema }),
|
|
16
|
+
]);
|
|
17
|
+
export const ProgressRecordSchema = z.strictObject({
|
|
18
|
+
version: z.literal(1), agentId: z.string().regex(/^[a-zA-Z0-9_-]{1,200}$/), tickId: z.string().regex(/^[a-zA-Z0-9_-]{1,200}$/),
|
|
19
|
+
sequence: z.number().int().positive().max(2000), at: z.iso.datetime({ offset: true }), event: ProgressEventSchema,
|
|
20
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Additive payee HTTP capabilities; no capability grants authority. */
|
|
2
|
+
export declare const payeeContract: {
|
|
3
|
+
readonly version: 1;
|
|
4
|
+
readonly product: "invoices";
|
|
5
|
+
readonly capabilities: readonly ["supplier-session-v1", "supplier-invoices-v1", "supplier-work-orders-v1", "supplier-work-order-requests-v1", "supplier-compensation-v2", "supplier-agent-connections-v1"];
|
|
6
|
+
};
|
|
7
|
+
/** A release manifest is compatible when its version and product match and every required capability is provided. */
|
|
8
|
+
export declare function compatibleRelease(value: unknown, product: string, provided: readonly string[]): boolean;
|
|
9
|
+
export declare const compatiblePayeeFrontend: (value: unknown) => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Additive payee HTTP capabilities; no capability grants authority. */
|
|
2
|
+
export const payeeContract = {
|
|
3
|
+
version: 1,
|
|
4
|
+
product: "invoices",
|
|
5
|
+
capabilities: ["supplier-session-v1", "supplier-invoices-v1", "supplier-work-orders-v1", "supplier-work-order-requests-v1", "supplier-compensation-v2", "supplier-agent-connections-v1"],
|
|
6
|
+
};
|
|
7
|
+
/** A release manifest is compatible when its version and product match and every required capability is provided. */
|
|
8
|
+
export function compatibleRelease(value, product, provided) {
|
|
9
|
+
if (!value || typeof value !== "object")
|
|
10
|
+
return false;
|
|
11
|
+
const release = value;
|
|
12
|
+
return release.version === 1 && release.product === product && Array.isArray(release.required) &&
|
|
13
|
+
release.required.length > 0 && release.required.every(capability => typeof capability === "string" && provided.includes(capability));
|
|
14
|
+
}
|
|
15
|
+
export const compatiblePayeeFrontend = (value) => compatibleRelease(value, payeeContract.product, payeeContract.capabilities);
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@multiagency/sdk",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "MultiAgency SDK: payee, compensation and owner-app schemas, typed payee and owner clients, and the shared release asset server.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"tanstack-intent"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/MultiAgency/platform.git"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/contract/index.d.ts",
|
|
20
|
+
"default": "./dist/contract/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./payee": {
|
|
23
|
+
"types": "./dist/contract/payee-entry.d.ts",
|
|
24
|
+
"default": "./dist/contract/payee-entry.js"
|
|
25
|
+
},
|
|
26
|
+
"./contract": {
|
|
27
|
+
"types": "./dist/contract/owner-contract.d.ts",
|
|
28
|
+
"default": "./dist/contract/owner-contract.js"
|
|
29
|
+
},
|
|
30
|
+
"./schemas/*": "./schemas/*",
|
|
31
|
+
"./release-server": {
|
|
32
|
+
"types": "./bin/release-server.d.mts",
|
|
33
|
+
"default": "./bin/release-server.mjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"multiagency-release-server": "bin/release-server.mjs"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"bin",
|
|
42
|
+
"schemas",
|
|
43
|
+
"skills",
|
|
44
|
+
"!skills/_artifacts",
|
|
45
|
+
"CHANGES.md",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE",
|
|
48
|
+
"THIRD-PARTY-NOTICES",
|
|
49
|
+
"provenance.json"
|
|
50
|
+
],
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@orpc/contract": "2.0.0-beta.47",
|
|
53
|
+
"@ag-ui/core": "1.0.3"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"zod": "^4.6.5"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/provenance.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@multiagency/sdk",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"wire": {
|
|
5
|
+
"payeeManifestVersion": 1,
|
|
6
|
+
"capabilities": [
|
|
7
|
+
"supplier-session-v1",
|
|
8
|
+
"supplier-invoices-v1",
|
|
9
|
+
"supplier-work-orders-v1",
|
|
10
|
+
"supplier-work-order-requests-v1",
|
|
11
|
+
"supplier-compensation-v2",
|
|
12
|
+
"supplier-agent-connections-v1"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"sourceHead": "766b3f3a25b6ae90ac4d4f1d8bb65ef5597f6f66",
|
|
16
|
+
"dirtyPaths": [],
|
|
17
|
+
"snapshot": {
|
|
18
|
+
"runDigest": "106ed6be37bc8f6b133006b49b74264cb9519807f20c3b70ad17cb2cbbf12136",
|
|
19
|
+
"overlayDiffSha256": null
|
|
20
|
+
},
|
|
21
|
+
"sources": {
|
|
22
|
+
"src/compensation-contract.ts": "3443b0690db7921d6dec04375d9281a2e1df3f4ffbe48c2b821e89af177f14c1",
|
|
23
|
+
"src/contract/agent-connection.ts": "cfe3ec3b3cdc4da2773b20de008e1a004f2862499d0df5831923637f8b39a746",
|
|
24
|
+
"src/contract/app-access.ts": "f5c792723dcaf870bf000265de9816b819035883cf79227e7de0cccc25681363",
|
|
25
|
+
"src/contract/app-client.ts": "d1ae48532320e8bfa5337f68b915f699566eea77d59d836ccd55e00676ea82b3",
|
|
26
|
+
"src/contract/app-consent.ts": "671d5904b448af50bc06aee19bdefa84359494b6cfe38cc0725042703ca6418a",
|
|
27
|
+
"src/contract/assets.ts": "b6cc3a160e488bfecf273b50e747e4640c8f4ba4d000bd6898db4f805ae9f310",
|
|
28
|
+
"src/contract/client.ts": "1eabd53e3119078d3c01a18850c180fab45385eec6ad210b92aa7fa158a03996",
|
|
29
|
+
"src/contract/gateway.ts": "e66bb199ab504b007e5a04617e0cf53b5b3d9641328a799c7df33f8901fa473b",
|
|
30
|
+
"src/contract/index.ts": "7c2daca088c9841b4e5e986825cd0501ef9f271fb4b9bc2804e83c93b5f938c5",
|
|
31
|
+
"src/contract/inputs.ts": "a7b16ff1ff05a65bc2bd6b8bdaa978296d912e45098d105e0a578a8174a029d3",
|
|
32
|
+
"src/contract/intents-account.ts": "8e88f6f41de28fdb48fa49243ccb4e0035dc7823586931658922927cf92f8fea",
|
|
33
|
+
"src/contract/orpc-client.ts": "94cbd34bc64bd06152f2dbf17d2ff6b270d1d3b703e3bb7019483bcce93eeb04",
|
|
34
|
+
"src/contract/owner-capabilities.ts": "1cee82270d4c9bf2984e71297515da0763b2e6b3c2d8052c96efed89813fb326",
|
|
35
|
+
"src/contract/owner-client.ts": "468a2e06784e95242087ecf45af805092de28af4e59ad0d445b29999b145b9f6",
|
|
36
|
+
"src/contract/owner-contract.ts": "339f63d7b585d652f1fd2175ebc94a5d8ef5e31a1f4730e554c2b0b89b24ab11",
|
|
37
|
+
"src/contract/owner-inputs.ts": "4328b6734a955fe524cf04852a0e4d9c20cf3c618416c5e91d857c98ffa1b837",
|
|
38
|
+
"src/contract/owner-outputs.ts": "59e9d8a712c4e6dc60075edaef86fee3f50a6b6c99273cd992431efbdefee75a",
|
|
39
|
+
"src/contract/package-version.ts": "a1495bd2343727a79d50e56af598990d3efce9e3253538b0d8b09feddc9e0736",
|
|
40
|
+
"src/contract/payee-entry.ts": "9557ec0f53dd4ab3411d3a81ccd82667f83766386332fb84e93a50caa8287bef",
|
|
41
|
+
"src/contract/payee.ts": "ec6e0c628be8592b997a5ceccfcd1ca18f891bb969731214fd4205b7e3f07a66",
|
|
42
|
+
"src/contract/permissions.ts": "fd0280c696cc070390360f20ff941f4ef2cf8143d81d55856103de43a935c93d",
|
|
43
|
+
"src/contract/proposals.ts": "8a9abb34f1ee09fcfb1de2cc2ced2773d3fa189f20faa0bc1a31ed9fae82beef",
|
|
44
|
+
"src/contract/run-log-schema.ts": "2ef522a589f6a70cff58e4ded63ddf41a6d3998b2fde96a1bf9176b363da3847",
|
|
45
|
+
"src/contract/run-progress-schema.ts": "5eead5bde373e8f058f7f42cf588c4a71e1960d5d7097e0381384c03f6a4bbfb",
|
|
46
|
+
"src/payee-contract.ts": "800260c35c1edbc6e8361f9213fe5f4ccdc22d8d7b1510db08a590f83a152351",
|
|
47
|
+
"src/contract/release-server.mjs": "a2177a0fc28bc19edefae2e5d5e8e11dffa3c4f099f604cee82457cb8eca51c7",
|
|
48
|
+
"src/contract/release-server.d.mts": "05fb535f8d1f3ff4aac62395b717144aecf1f4b0c5b388ca83d8b4cb677d2764",
|
|
49
|
+
"docs/sdk-changes.md": "969bd9a4fcc3774660dea0717798e5e5e300f54d40dc88b104fa75122a0ce567",
|
|
50
|
+
"src/contract/README.md": "e80e5cbbab40fef5d4a8deadb90b02133b2998df7fc17ff031910e818e6909a9",
|
|
51
|
+
"LICENSE": "0f90c37abe95e72f99ddb9b9dfc5e54b663d8bfed929d4c261669059443ba822",
|
|
52
|
+
"src/contract/skills/app-server/SKILL.md": "0bef6c331bc86eeae588c0c54ce2932c25cb5d2d07107912c728213bcf943071",
|
|
53
|
+
"src/contract/skills/getting-started/SKILL.md": "c8b2bce01aa946c8a6c3540266208e93e3ae08ddb7cf5deff7a6ccae2b92f622",
|
|
54
|
+
"src/contract/skills/owner-workflows/SKILL.md": "e6b88d764aa8b6cafd1a26ad7a21cbbd842625a9b145c96dd922a6ef6ae080ed",
|
|
55
|
+
"src/contract/skills/payee-workflows/SKILL.md": "efa1bd5e07d4b06405d54c5fc424d9357ab336883bdd55e66bbd7094bb01441a"
|
|
56
|
+
},
|
|
57
|
+
"sourcesDirty": [],
|
|
58
|
+
"node": "v24.22.1",
|
|
59
|
+
"typescript": "Version 7.0.2",
|
|
60
|
+
"builtAt": "2026-10-31T04:39:35.856Z"
|
|
61
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"id": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"format": "uuid",
|
|
8
|
+
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
9
|
+
},
|
|
10
|
+
"label": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"minLength": 1,
|
|
13
|
+
"maxLength": 80
|
|
14
|
+
},
|
|
15
|
+
"role": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"enum": [
|
|
18
|
+
"payee"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"permissions": {
|
|
22
|
+
"minItems": 1,
|
|
23
|
+
"type": "array",
|
|
24
|
+
"items": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": [
|
|
27
|
+
"compensation.read",
|
|
28
|
+
"compensation.submit"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"host": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"minLength": 1
|
|
35
|
+
},
|
|
36
|
+
"instance": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 1
|
|
39
|
+
},
|
|
40
|
+
"account": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"minLength": 2
|
|
43
|
+
},
|
|
44
|
+
"agentId": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"minLength": 1
|
|
47
|
+
},
|
|
48
|
+
"createdAt": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"format": "date-time",
|
|
51
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
|
52
|
+
},
|
|
53
|
+
"expiresAt": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"format": "date-time",
|
|
56
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
|
57
|
+
},
|
|
58
|
+
"revoked": {
|
|
59
|
+
"type": "boolean"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"required": [
|
|
63
|
+
"id",
|
|
64
|
+
"label",
|
|
65
|
+
"role",
|
|
66
|
+
"permissions",
|
|
67
|
+
"host",
|
|
68
|
+
"instance",
|
|
69
|
+
"account",
|
|
70
|
+
"agentId",
|
|
71
|
+
"createdAt",
|
|
72
|
+
"expiresAt",
|
|
73
|
+
"revoked"
|
|
74
|
+
],
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"label": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"minLength": 1,
|
|
8
|
+
"maxLength": 80
|
|
9
|
+
},
|
|
10
|
+
"ttlSeconds": {
|
|
11
|
+
"default": 3600,
|
|
12
|
+
"type": "integer",
|
|
13
|
+
"minimum": 60,
|
|
14
|
+
"maximum": 86400
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": [
|
|
18
|
+
"label",
|
|
19
|
+
"ttlSeconds"
|
|
20
|
+
],
|
|
21
|
+
"additionalProperties": false
|
|
22
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"connections": {
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"id": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"format": "uuid",
|
|
13
|
+
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
|
14
|
+
},
|
|
15
|
+
"label": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"minLength": 1,
|
|
18
|
+
"maxLength": 80
|
|
19
|
+
},
|
|
20
|
+
"role": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": [
|
|
23
|
+
"payee"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"permissions": {
|
|
27
|
+
"minItems": 1,
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": [
|
|
32
|
+
"compensation.read",
|
|
33
|
+
"compensation.submit"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"host": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"minLength": 1
|
|
40
|
+
},
|
|
41
|
+
"instance": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"minLength": 1
|
|
44
|
+
},
|
|
45
|
+
"account": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"minLength": 2
|
|
48
|
+
},
|
|
49
|
+
"agentId": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"minLength": 1
|
|
52
|
+
},
|
|
53
|
+
"createdAt": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"format": "date-time",
|
|
56
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
|
57
|
+
},
|
|
58
|
+
"expiresAt": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"format": "date-time",
|
|
61
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
|
62
|
+
},
|
|
63
|
+
"revoked": {
|
|
64
|
+
"type": "boolean"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"required": [
|
|
68
|
+
"id",
|
|
69
|
+
"label",
|
|
70
|
+
"role",
|
|
71
|
+
"permissions",
|
|
72
|
+
"host",
|
|
73
|
+
"instance",
|
|
74
|
+
"account",
|
|
75
|
+
"agentId",
|
|
76
|
+
"createdAt",
|
|
77
|
+
"expiresAt",
|
|
78
|
+
"revoked"
|
|
79
|
+
],
|
|
80
|
+
"additionalProperties": false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"required": [
|
|
85
|
+
"connections"
|
|
86
|
+
],
|
|
87
|
+
"additionalProperties": false
|
|
88
|
+
}
|