@ziggs-ai/contracts 0.6.0 → 0.7.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.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * How a credential was authorized.
3
+ *
4
+ * The server stamps this on every operator key it mints, and clients read it
5
+ * back: `isDirectoryBoarded` — is this an assistant that boarded through the
6
+ * connector directory, and therefore gets the listed tool surface rather than
7
+ * the whole one — is a predicate over exactly this set.
8
+ *
9
+ * It lives here because both sides need the same answer and neither owns it.
10
+ * The backend schema held the list and api-client restated the two values it
11
+ * happened to care about, so a rail added on the server was invisible to the
12
+ * client until somebody remembered: a third consent door would have served
13
+ * the full catalogue to every credential from it.
14
+ *
15
+ * The values record how the credential was AUTHORIZED, never which UI the
16
+ * person was looking at. "Dashboard" and "API/SDK" were the obvious pair to
17
+ * want and cannot be told apart: one route serves both, and a signed-in human
18
+ * and a script under a user session arrive identically. Recording "dashboard"
19
+ * would be a guess dressed as a fact.
20
+ */
21
+ export declare const OPERATOR_KEY_ISSUED_VIA: {
22
+ /** The default key minted for a new account at registration. */
23
+ readonly SIGNUP: "signup";
24
+ /** `POST /operator-tokens` under a signed-in human's session. */
25
+ readonly SESSION: "session";
26
+ /** `POST /operator-tokens` from another operator key; `issuedByKeyId` says which. */
27
+ readonly DERIVED: "derived";
28
+ /** The agent-bound key minted by agent create or rotate. */
29
+ readonly AGENT_PROVISIONING: "agent_provisioning";
30
+ /** The MCP OAuth authorization-code consent flow. */
31
+ readonly MCP_OAUTH: "mcp_oauth";
32
+ /** The MCP OAuth device-code flow. */
33
+ readonly DEVICE_CODE: "device_code";
34
+ };
35
+ export type OperatorKeyIssuedVia = (typeof OPERATOR_KEY_ISSUED_VIA)[keyof typeof OPERATOR_KEY_ISSUED_VIA];
36
+ /**
37
+ * The doors that board a connected assistant through the connector directory.
38
+ *
39
+ * Ask this rather than comparing to one value. Both consent rails board an
40
+ * assistant the same way and both want the same narrowed surface, but the
41
+ * server records them as the different acts they are — an equality test
42
+ * against one of them serves the whole catalogue to every credential from the
43
+ * other.
44
+ */
45
+ export declare const DIRECTORY_BOARDED_ISSUED_VIA: readonly OperatorKeyIssuedVia[];
46
+ /** Did a person board this credential through the connector directory? */
47
+ export declare function isDirectoryBoardedIssuedVia(issuedVia: string | null | undefined): boolean;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DIRECTORY_BOARDED_ISSUED_VIA = exports.OPERATOR_KEY_ISSUED_VIA = void 0;
4
+ exports.isDirectoryBoardedIssuedVia = isDirectoryBoardedIssuedVia;
5
+ /**
6
+ * How a credential was authorized.
7
+ *
8
+ * The server stamps this on every operator key it mints, and clients read it
9
+ * back: `isDirectoryBoarded` — is this an assistant that boarded through the
10
+ * connector directory, and therefore gets the listed tool surface rather than
11
+ * the whole one — is a predicate over exactly this set.
12
+ *
13
+ * It lives here because both sides need the same answer and neither owns it.
14
+ * The backend schema held the list and api-client restated the two values it
15
+ * happened to care about, so a rail added on the server was invisible to the
16
+ * client until somebody remembered: a third consent door would have served
17
+ * the full catalogue to every credential from it.
18
+ *
19
+ * The values record how the credential was AUTHORIZED, never which UI the
20
+ * person was looking at. "Dashboard" and "API/SDK" were the obvious pair to
21
+ * want and cannot be told apart: one route serves both, and a signed-in human
22
+ * and a script under a user session arrive identically. Recording "dashboard"
23
+ * would be a guess dressed as a fact.
24
+ */
25
+ exports.OPERATOR_KEY_ISSUED_VIA = {
26
+ /** The default key minted for a new account at registration. */
27
+ SIGNUP: 'signup',
28
+ /** `POST /operator-tokens` under a signed-in human's session. */
29
+ SESSION: 'session',
30
+ /** `POST /operator-tokens` from another operator key; `issuedByKeyId` says which. */
31
+ DERIVED: 'derived',
32
+ /** The agent-bound key minted by agent create or rotate. */
33
+ AGENT_PROVISIONING: 'agent_provisioning',
34
+ /** The MCP OAuth authorization-code consent flow. */
35
+ MCP_OAUTH: 'mcp_oauth',
36
+ /** The MCP OAuth device-code flow. */
37
+ DEVICE_CODE: 'device_code',
38
+ };
39
+ /**
40
+ * The doors that board a connected assistant through the connector directory.
41
+ *
42
+ * Ask this rather than comparing to one value. Both consent rails board an
43
+ * assistant the same way and both want the same narrowed surface, but the
44
+ * server records them as the different acts they are — an equality test
45
+ * against one of them serves the whole catalogue to every credential from the
46
+ * other.
47
+ */
48
+ exports.DIRECTORY_BOARDED_ISSUED_VIA = [
49
+ exports.OPERATOR_KEY_ISSUED_VIA.MCP_OAUTH,
50
+ exports.OPERATOR_KEY_ISSUED_VIA.DEVICE_CODE,
51
+ ];
52
+ /** Did a person board this credential through the connector directory? */
53
+ function isDirectoryBoardedIssuedVia(issuedVia) {
54
+ return exports.DIRECTORY_BOARDED_ISSUED_VIA.includes(issuedVia);
55
+ }
package/dist/error.d.ts CHANGED
@@ -3,9 +3,18 @@
3
3
  *
4
4
  * Every handler error is rendered as this body with an HTTP status, so a
5
5
  * client can render the real message instead of a boolean.
6
+ *
7
+ * `code` is the machine-readable reason, present when the handler supplied
8
+ * one (`GRANT_REVOKED`, `GRANT_PARTY_MISMATCH`, `NO_USER_CONNECTION`, …). The
9
+ * global filter has emitted it since ZIG-702 and api-client has read it since
10
+ * then, and this contract did not say so — which is how a shape meant to be
11
+ * the one description of the wire came to describe less of it than both sides
12
+ * already relied on. A client branching on `code` is the point: `error` is for
13
+ * a person to read, `code` is for a program to decide with.
6
14
  */
7
15
  export interface ApiErrorBody {
8
16
  error: string;
17
+ code?: string;
9
18
  }
10
19
  /** True when a response body is the API's error shape. */
11
20
  export declare function isApiErrorBody(body: unknown): body is ApiErrorBody;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * GENERATED from the backend OpenAPI spec — do not edit.
3
+ * Family: agreements. Regenerate: backend 'pnpm docs:generate' then this script.
4
+ */
5
+ export type AgreementPartySide = {
6
+ principal: string | null;
7
+ actor: string | null;
8
+ };
9
+ export type AgreementParties = {
10
+ payer: AgreementPartySide;
11
+ provider: AgreementPartySide;
12
+ proposedTo: AgreementPartySide;
13
+ creator: AgreementPartySide;
14
+ };
15
+ export type AgreementTerms = {
16
+ lifecycle: "open" | "time-bound" | "count-bound";
17
+ expiresAt: string | null;
18
+ maxExecutions: number | null;
19
+ description: string;
20
+ billing?: "total" | "per_task";
21
+ requiredConnections: Array<unknown>;
22
+ wakeCeiling?: number;
23
+ };
24
+ export type AgreementHeld = {
25
+ amount: number;
26
+ currency: "pez";
27
+ state: "held" | "released" | "refunded";
28
+ agreementId: string;
29
+ };
30
+ export type AgreementAllocation = {
31
+ childAgreementId: string;
32
+ childTaskId: string | null;
33
+ amount: number;
34
+ status: "allocated" | "completed" | "released" | "failed";
35
+ };
36
+ export type AgreementMoney = {
37
+ price: number | null;
38
+ paymentStatus: "none" | "held" | "allocated" | "paid" | "refunded" | "metered";
39
+ transactionId: string | null;
40
+ allocations: Array<AgreementAllocation>;
41
+ held: AgreementHeld | null;
42
+ };
43
+ export type AgreementProposal = {
44
+ status: "pending" | "approved" | "rejected" | "expired" | "countered" | null;
45
+ respondedBy: string | null;
46
+ proposedAt: string | null;
47
+ respondedAt: string | null;
48
+ };
49
+ export type AgreementApproval = {
50
+ partyId: string;
51
+ role: "payer" | "provider" | "proposedTo" | "principal";
52
+ status: "pending" | "self-consent" | "approved" | "rejected";
53
+ respondedAt: string | null;
54
+ respondedBy?: string | null;
55
+ };
56
+ export type AgreementUserReport = {
57
+ userId: string;
58
+ message: string;
59
+ createdAt: string;
60
+ };
61
+ export type AgreementActivationFailure = {
62
+ message: string;
63
+ at: string;
64
+ };
65
+ export type AgreementClaimSeats = {
66
+ maxClaims: number | null;
67
+ claimsUsed: number;
68
+ };
69
+ export type AgreementConnectionRequest = {
70
+ serverUrl: string;
71
+ tools: Array<string>;
72
+ reason: string | null;
73
+ connectionReady: boolean;
74
+ };
75
+ export type AgreementRead = {
76
+ agreementId: string;
77
+ rootAgreementId: string | null;
78
+ parentAgreementId: string | null;
79
+ parties: AgreementParties;
80
+ terms: AgreementTerms;
81
+ money: AgreementMoney;
82
+ proposal: AgreementProposal;
83
+ status: "draft" | "open" | "active" | "fulfilled" | "cancelled" | "refunded";
84
+ engagementKind: "hire" | "service" | "link";
85
+ formedBy: "principal" | "agent";
86
+ orgId: string | null;
87
+ userOutcomeSatisfaction: "positive" | "negative" | null;
88
+ approvals: Array<AgreementApproval>;
89
+ userReports: Array<AgreementUserReport>;
90
+ activationFailure: AgreementActivationFailure | null;
91
+ providerPinned: boolean;
92
+ claimSeats: AgreementClaimSeats | null;
93
+ listingPausedAt?: string | null;
94
+ metadata: Record<string, unknown>;
95
+ connectionRequest?: AgreementConnectionRequest;
96
+ createdAt: string;
97
+ updatedAt: string;
98
+ partyPresentations?: Record<string, unknown>;
99
+ peer?: {
100
+ id?: string;
101
+ name?: string;
102
+ };
103
+ hireClosed?: {
104
+ kind?: "dark" | "paused" | "full";
105
+ reason?: string;
106
+ } | null;
107
+ };
108
+ export type AgreementGetResponse = {
109
+ agreement: AgreementRead;
110
+ };
111
+ export type AgreementListResponse = {
112
+ agreements: Array<AgreementRead>;
113
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -32,7 +32,7 @@ export type GrantView = {
32
32
  basis?: GrantBasis;
33
33
  };
34
34
  export type UnreadableRail = {
35
- rail: string;
35
+ rail: "context" | "connection" | "wallet" | "consent" | "inbox";
36
36
  requiredScope: string;
37
37
  };
38
38
  export type ListGrantsResult = {
package/dist/index.d.ts CHANGED
@@ -10,11 +10,13 @@ export * from './vocabulary';
10
10
  export * from './chat';
11
11
  export * from './inbox';
12
12
  export * from './error';
13
+ export * from './credentials';
13
14
  export * from './socket';
14
15
  export * from './generated/agents';
15
16
  export * from './generated/grants';
16
17
  export * from './generated/payments';
17
18
  export * from './generated/connections';
19
+ export * from './generated/agreements';
18
20
  export * from './generated/artifacts';
19
21
  export * from './identifiers';
20
22
  export * from './generated/chat-send';
package/dist/index.js CHANGED
@@ -26,12 +26,14 @@ __exportStar(require("./vocabulary"), exports);
26
26
  __exportStar(require("./chat"), exports);
27
27
  __exportStar(require("./inbox"), exports);
28
28
  __exportStar(require("./error"), exports);
29
+ __exportStar(require("./credentials"), exports);
29
30
  __exportStar(require("./socket"), exports);
30
31
  // Generated from the backend OpenAPI spec (ZIG-1668). See scripts/generate-wire.mjs.
31
32
  __exportStar(require("./generated/agents"), exports);
32
33
  __exportStar(require("./generated/grants"), exports);
33
34
  __exportStar(require("./generated/payments"), exports);
34
35
  __exportStar(require("./generated/connections"), exports);
36
+ __exportStar(require("./generated/agreements"), exports);
35
37
  __exportStar(require("./generated/artifacts"), exports);
36
38
  __exportStar(require("./identifiers"), exports);
37
39
  __exportStar(require("./generated/chat-send"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/contracts",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Wire contracts for the Ziggs API — response shapes, error body, and socket events, shared by every client.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",