@dork-labs/cloud-api 0.75.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.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -0
  3. package/dist/billing.d.ts +328 -0
  4. package/dist/billing.d.ts.map +1 -0
  5. package/dist/billing.js +267 -0
  6. package/dist/billing.js.map +1 -0
  7. package/dist/client.d.ts +130 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +192 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/connections.d.ts +281 -0
  12. package/dist/connections.d.ts.map +1 -0
  13. package/dist/connections.js +241 -0
  14. package/dist/connections.js.map +1 -0
  15. package/dist/index.d.ts +31 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +31 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/inference.d.ts +123 -0
  20. package/dist/inference.d.ts.map +1 -0
  21. package/dist/inference.js +114 -0
  22. package/dist/inference.js.map +1 -0
  23. package/dist/instances.d.ts +60 -0
  24. package/dist/instances.d.ts.map +1 -0
  25. package/dist/instances.js +65 -0
  26. package/dist/instances.js.map +1 -0
  27. package/dist/primitives.d.ts +74 -0
  28. package/dist/primitives.d.ts.map +1 -0
  29. package/dist/primitives.js +98 -0
  30. package/dist/primitives.js.map +1 -0
  31. package/dist/problem.d.ts +96 -0
  32. package/dist/problem.d.ts.map +1 -0
  33. package/dist/problem.js +94 -0
  34. package/dist/problem.js.map +1 -0
  35. package/dist/remote.d.ts +268 -0
  36. package/dist/remote.d.ts.map +1 -0
  37. package/dist/remote.js +267 -0
  38. package/dist/remote.js.map +1 -0
  39. package/dist/routes.d.ts +273 -0
  40. package/dist/routes.d.ts.map +1 -0
  41. package/dist/routes.js +302 -0
  42. package/dist/routes.js.map +1 -0
  43. package/dist/seats.d.ts +529 -0
  44. package/dist/seats.d.ts.map +1 -0
  45. package/dist/seats.js +266 -0
  46. package/dist/seats.js.map +1 -0
  47. package/dist/session.d.ts +135 -0
  48. package/dist/session.d.ts.map +1 -0
  49. package/dist/session.js +143 -0
  50. package/dist/session.js.map +1 -0
  51. package/fixtures/v1/billing/balance-owed.json +16 -0
  52. package/fixtures/v1/billing/balance.json +16 -0
  53. package/fixtures/v1/billing/entitlements-free.json +34 -0
  54. package/fixtures/v1/billing/hosted-page.json +3 -0
  55. package/fixtures/v1/billing/nudge.json +9 -0
  56. package/fixtures/v1/billing/price-list.json +13 -0
  57. package/fixtures/v1/billing/statement.json +5 -0
  58. package/fixtures/v1/billing/usage-by-model.json +21 -0
  59. package/fixtures/v1/connections/catalog.json +12 -0
  60. package/fixtures/v1/connections/events-ack.json +3 -0
  61. package/fixtures/v1/connections/events-pull.json +16 -0
  62. package/fixtures/v1/connections/execution.json +12 -0
  63. package/fixtures/v1/connections/list.json +16 -0
  64. package/fixtures/v1/connections/usage.json +16 -0
  65. package/fixtures/v1/index.json +58 -0
  66. package/fixtures/v1/inference/models.json +17 -0
  67. package/fixtures/v1/inference/token-revoke.json +3 -0
  68. package/fixtures/v1/inference/token.json +14 -0
  69. package/fixtures/v1/instances/heartbeat.json +5 -0
  70. package/fixtures/v1/instances/list.json +15 -0
  71. package/fixtures/v1/instances/revoke.json +3 -0
  72. package/fixtures/v1/problem/handle-tombstoned.json +6 -0
  73. package/fixtures/v1/problem/person-seat-required.json +7 -0
  74. package/fixtures/v1/problem/unauthenticated.json +7 -0
  75. package/fixtures/v1/remote/address.json +5 -0
  76. package/fixtures/v1/remote/command-keepalive.json +4 -0
  77. package/fixtures/v1/remote/command-open.json +6 -0
  78. package/fixtures/v1/remote/commands-ack.json +3 -0
  79. package/fixtures/v1/remote/credential.json +7 -0
  80. package/fixtures/v1/remote/custom-address.json +12 -0
  81. package/fixtures/v1/remote/designation.json +5 -0
  82. package/fixtures/v1/remote/enrolment.json +5 -0
  83. package/fixtures/v1/remote/events.json +3 -0
  84. package/fixtures/v1/remote/open.json +5 -0
  85. package/fixtures/v1/remote/status-closed.json +7 -0
  86. package/fixtures/v1/remote/status-open.json +10 -0
  87. package/fixtures/v1/remote/wake-token.json +5 -0
  88. package/fixtures/v1/seats/addons.json +11 -0
  89. package/fixtures/v1/seats/agent.json +9 -0
  90. package/fixtures/v1/seats/grants.json +20 -0
  91. package/fixtures/v1/seats/inbox-browse.json +17 -0
  92. package/fixtures/v1/seats/inbox-pull.json +17 -0
  93. package/fixtures/v1/seats/invitation.json +9 -0
  94. package/fixtures/v1/seats/members.json +12 -0
  95. package/fixtures/v1/seats/org.json +7 -0
  96. package/fixtures/v1/seats/presence.json +6 -0
  97. package/fixtures/v1/seats/seat.json +21 -0
  98. package/fixtures/v1/session/account-export.json +6 -0
  99. package/fixtures/v1/session/device-code.json +8 -0
  100. package/fixtures/v1/session/device-token-pending.json +4 -0
  101. package/fixtures/v1/session/device-token.json +7 -0
  102. package/fixtures/v1/session/signed-in.json +14 -0
  103. package/fixtures/v1/session/signed-out.json +4 -0
  104. package/package.json +58 -0
package/dist/seats.js ADDED
@@ -0,0 +1,266 @@
1
+ import { z } from 'zod';
2
+ import { IdSchema, TimestampSchema, pageOf } from './primitives.js';
3
+ /** Whether an organization is one person`s own or a shared one. */
4
+ export const OrgKindSchema = z
5
+ .enum(['personal', 'org'])
6
+ .describe('Whether an organization is one person`s own or a shared one.');
7
+ /** What a member may do in an organization. */
8
+ export const MemberRoleSchema = z
9
+ .enum(['owner', 'admin', 'member'])
10
+ .describe('What a member may do in an organization.');
11
+ /** An organization: the unit seats, addresses and billing hang off. */
12
+ export const OrgSchema = z
13
+ .object({
14
+ id: IdSchema,
15
+ slug: z.string().describe('The short name that appears in a canonical address.'),
16
+ name: z.string(),
17
+ kind: OrgKindSchema,
18
+ createdAt: TimestampSchema,
19
+ })
20
+ .describe('An organization: the unit seats, addresses and billing hang off.');
21
+ /** `POST /v1/orgs`. */
22
+ export const OrgCreateRequestSchema = z
23
+ .object({ slug: z.string().min(1), name: z.string().min(1) })
24
+ .describe('Create an organization.');
25
+ /** `PATCH /v1/orgs/{orgId}`. */
26
+ export const OrgUpdateRequestSchema = z
27
+ .object({ name: z.string().min(1).optional(), slug: z.string().min(1).optional() })
28
+ .describe('Rename an organization or change its slug.');
29
+ /** `GET /v1/orgs`. */
30
+ export const OrgListResponseSchema = pageOf(OrgSchema, 'A page of the organizations the caller belongs to.');
31
+ /** One person`s membership of one organization. */
32
+ export const MemberSchema = z
33
+ .object({
34
+ id: IdSchema,
35
+ orgId: IdSchema,
36
+ userId: IdSchema,
37
+ role: MemberRoleSchema,
38
+ createdAt: TimestampSchema,
39
+ })
40
+ .describe('One person`s membership of one organization.');
41
+ /** `GET /v1/orgs/{orgId}/members`. */
42
+ export const MemberListResponseSchema = pageOf(MemberSchema, 'A page of an organization`s members.');
43
+ /** How far an invitation has got. */
44
+ export const InvitationStatusSchema = z
45
+ .enum(['pending', 'accepted', 'rejected', 'canceled'])
46
+ .describe('How far an invitation has got.');
47
+ /** An outstanding or settled invitation to join an organization. */
48
+ export const InvitationSchema = z
49
+ .object({
50
+ id: IdSchema,
51
+ orgId: IdSchema,
52
+ email: z.string(),
53
+ role: MemberRoleSchema,
54
+ status: InvitationStatusSchema,
55
+ expiresAt: TimestampSchema,
56
+ createdAt: TimestampSchema,
57
+ })
58
+ .describe('An outstanding or settled invitation to join an organization.');
59
+ /** `POST /v1/orgs/{orgId}/invitations`. */
60
+ export const InvitationCreateRequestSchema = z
61
+ .object({ email: z.string().min(1), role: MemberRoleSchema })
62
+ .describe('Invite somebody to an organization.');
63
+ /** `GET /v1/orgs/{orgId}/invitations`. */
64
+ export const InvitationListResponseSchema = pageOf(InvitationSchema, 'A page of an organization`s invitations.');
65
+ /** An agent identity an organization has registered. */
66
+ export const AgentSchema = z
67
+ .object({
68
+ id: IdSchema,
69
+ orgId: IdSchema,
70
+ ownerMemberId: IdSchema.nullable().describe('The member who owns this agent, or null when nobody does yet.'),
71
+ displayName: z.string(),
72
+ emoji: z.string().optional(),
73
+ color: z.string().optional(),
74
+ imageUrl: z.string().url().optional(),
75
+ createdAt: TimestampSchema,
76
+ retiredAt: TimestampSchema.optional(),
77
+ })
78
+ .describe('An agent identity an organization has registered.');
79
+ /**
80
+ * `POST /v1/orgs/{orgId}/agents` — an instance asserts a claim to an agent
81
+ * identity. It mints nothing; a person approves the claim separately.
82
+ */
83
+ export const AgentClaimRequestSchema = z
84
+ .object({
85
+ displayName: z.string().min(1),
86
+ instanceId: IdSchema,
87
+ emoji: z.string().optional(),
88
+ color: z.string().optional(),
89
+ })
90
+ .describe('An instance asserting a claim to an agent identity. Mints nothing until a person approves it.');
91
+ /** The state of an agent claim. */
92
+ export const AgentClaimSchema = z
93
+ .object({
94
+ claimId: IdSchema,
95
+ agentId: IdSchema,
96
+ instanceId: IdSchema,
97
+ status: z.enum(['pending', 'approved', 'rejected', 'expired']),
98
+ createdAt: TimestampSchema,
99
+ approvedAt: TimestampSchema.nullable(),
100
+ })
101
+ .describe('The state of an agent claim awaiting a person`s approval.');
102
+ /** `GET /v1/orgs/{orgId}/agents`. */
103
+ export const AgentListResponseSchema = pageOf(AgentSchema, 'A page of an organization`s agents.');
104
+ /** Whether a seat holds a person or an agent. */
105
+ export const SeatKindSchema = z
106
+ .enum(['person', 'agent'])
107
+ .describe('Whether a seat holds a person or an agent.');
108
+ /** Where a seat is in its lifecycle. */
109
+ export const SeatStatusSchema = z
110
+ .enum(['unassigned', 'assigned', 'suspended', 'released'])
111
+ .describe('Where a seat is in its lifecycle.');
112
+ /** Whether an address is live or has been retired. */
113
+ export const AddressStatusSchema = z
114
+ .enum(['active', 'retired'])
115
+ .describe('Whether an address is live or has been retired.');
116
+ /** A routable address issued to a seat. */
117
+ export const AddressSchema = z
118
+ .object({
119
+ id: IdSchema,
120
+ orgId: IdSchema,
121
+ seatId: IdSchema,
122
+ handle: z.string().describe('The local part of the address, unique within the organization.'),
123
+ canonical: z.string().describe('The full `dork:<org-slug>/<handle>` form.'),
124
+ status: AddressStatusSchema,
125
+ issuedAt: TimestampSchema,
126
+ retiredAt: TimestampSchema.optional(),
127
+ })
128
+ .describe('A routable address issued to a seat.');
129
+ /** `POST /v1/addresses`. */
130
+ export const AddressCreateRequestSchema = z
131
+ .object({ seatId: IdSchema, handle: z.string().min(1) })
132
+ .describe('Issue an address to a seat.');
133
+ /** One seat in an organization. */
134
+ export const SeatSchema = z
135
+ .object({
136
+ id: IdSchema,
137
+ orgId: IdSchema,
138
+ kind: SeatKindSchema,
139
+ status: SeatStatusSchema,
140
+ subject: z
141
+ .object({ kind: z.enum(['user', 'agent']), id: IdSchema })
142
+ .nullable()
143
+ .describe('Who or what currently occupies the seat, or null when nobody does.'),
144
+ address: AddressSchema.nullable(),
145
+ createdAt: TimestampSchema,
146
+ assignedAt: TimestampSchema.optional(),
147
+ releasedAt: TimestampSchema.optional(),
148
+ })
149
+ .describe('One seat in an organization.');
150
+ /** `GET /v1/orgs/{orgId}/seats`. */
151
+ export const SeatListResponseSchema = pageOf(SeatSchema, 'A page of an organization`s seats.');
152
+ /** `POST /v1/seats/{seatId}/assign`. */
153
+ export const SeatAssignRequestSchema = z
154
+ .object({ subject: z.object({ kind: z.enum(['user', 'agent']), id: IdSchema }) })
155
+ .describe('Put a person or an agent into a seat.');
156
+ /** Who may reach a seat, and for what. */
157
+ export const GrantSchema = z
158
+ .object({
159
+ id: IdSchema,
160
+ seatId: IdSchema,
161
+ granteeKind: z
162
+ .enum(['org', 'seat', 'connected-channel', 'public'])
163
+ .describe('What kind of thing the grant is about.'),
164
+ granteeRef: IdSchema.nullable().describe('Which one, or null when the kind is enough (`public`).'),
165
+ capability: z
166
+ .enum(['address', 'trigger'])
167
+ .describe('What the grantee may do: reach the address, or trigger the seat.'),
168
+ effect: z.enum(['allow', 'deny']).describe('Deny wins over allow.'),
169
+ })
170
+ .describe('One rule about who may reach a seat, and for what.');
171
+ /** `PUT /v1/seats/{seatId}/grants` — replace the whole set in one call. */
172
+ export const GrantReplaceRequestSchema = z
173
+ .object({ grants: z.array(GrantSchema.omit({ id: true, seatId: true })) })
174
+ .describe('Replace a seat`s entire grant set. A partial update is not offered, so no two clients can interleave.');
175
+ /** `GET /v1/seats/{seatId}/grants`. */
176
+ export const GrantListResponseSchema = z
177
+ .object({ grants: z.array(GrantSchema) })
178
+ .describe('A seat`s entire grant set.');
179
+ /** Something attached to a seat beyond what it includes by default. */
180
+ export const AddonSchema = z
181
+ .object({
182
+ id: IdSchema,
183
+ seatId: IdSchema,
184
+ kind: z
185
+ .string()
186
+ .describe('An opaque add-on identifier. The set is never enumerated in this package.'),
187
+ status: z.enum(['attached', 'detached']),
188
+ attachedAt: TimestampSchema,
189
+ detachedAt: TimestampSchema.optional(),
190
+ })
191
+ .describe('Something attached to a seat beyond what it includes by default.');
192
+ /** `POST /v1/seats/{seatId}/addons`. */
193
+ export const AddonAttachRequestSchema = z
194
+ .object({ kind: IdSchema.describe('An opaque identifier the server supplied earlier.') })
195
+ .describe('Attach an add-on to a seat.');
196
+ /** `GET /v1/seats/{seatId}/addons`. */
197
+ export const AddonListResponseSchema = z
198
+ .object({ addons: z.array(AddonSchema) })
199
+ .describe('Everything attached to a seat.');
200
+ /** Where something arrived from. */
201
+ export const InboxSourceKindSchema = z
202
+ .enum(['email', 'a2a', 'seat', 'connected-channel'])
203
+ .describe('Where an inbox item arrived from.');
204
+ /**
205
+ * One item leased from a seat`s inbox.
206
+ *
207
+ * `leaseToken` is the receipt that acknowledges exactly this delivery. It
208
+ * mirrors the connector event contract rather than inventing a second design.
209
+ */
210
+ export const InboxItemSchema = z
211
+ .object({
212
+ id: IdSchema,
213
+ leaseToken: z.string().min(1).describe('The receipt that acknowledges exactly this delivery.'),
214
+ receivedAt: TimestampSchema,
215
+ expiresAt: TimestampSchema.describe('When the lease lapses and the item becomes pullable again.'),
216
+ sourceKind: InboxSourceKindSchema,
217
+ sourceRef: z.string().describe('Which sender, in whatever form that source names one.'),
218
+ envelope: z.unknown().describe('The source-shaped metadata of the item.'),
219
+ bodyUrl: z.string().url().describe('Where to fetch the item body.'),
220
+ sizeBytes: z.number().int().nonnegative(),
221
+ })
222
+ .describe('One item leased from a seat`s inbox.');
223
+ /** `POST /v1/seats/{seatId}/inbox/pull`. */
224
+ export const InboxPullRequestSchema = z
225
+ .object({
226
+ limit: z.number().int().min(1).max(100).optional().describe('Defaults to 50, capped at 100.'),
227
+ })
228
+ .describe('Lease a batch of inbox items. Cursor-free by design, exactly like the connector event pull.');
229
+ /** A leased batch of inbox items. */
230
+ export const InboxPullResponseSchema = z
231
+ .object({ items: z.array(InboxItemSchema) })
232
+ .describe('A leased batch of inbox items. No cursor, by design.');
233
+ /** `POST /v1/seats/{seatId}/inbox/ack`. */
234
+ export const InboxAckRequestSchema = z
235
+ .object({
236
+ items: z
237
+ .array(z.object({ id: IdSchema, leaseToken: z.string().min(1) }))
238
+ .min(1)
239
+ .max(100),
240
+ })
241
+ .describe('Settle inbox leases with exact receipts. One to a hundred at a time.');
242
+ /** How many inbox leases were settled. */
243
+ export const InboxAckResponseSchema = z
244
+ .object({ acknowledged: z.number().int().nonnegative() })
245
+ .describe('How many inbox leases the server settled.');
246
+ /**
247
+ * `GET /v1/seats/{seatId}/inbox` — a read-only cursor-paginated browse.
248
+ *
249
+ * Separate from the pull on purpose: it takes no lease and changes no status,
250
+ * which is what stops an interface refresh from acknowledging somebody`s mail.
251
+ */
252
+ export const InboxBrowseResponseSchema = pageOf(InboxItemSchema.omit({ leaseToken: true }), 'A read-only page of a seat`s inbox. Takes no lease and changes no status.');
253
+ /** How reachable a seat is right now. */
254
+ export const PresenceStateSchema = z
255
+ .enum(['offline', 'unknown', 'reachable', 'active'])
256
+ .describe('How reachable a seat is right now.');
257
+ /** `GET /v1/seats/{seatId}/presence`. */
258
+ export const PresenceSchema = z
259
+ .object({
260
+ seatId: IdSchema,
261
+ state: PresenceStateSchema,
262
+ lastSeenAt: TimestampSchema.nullable(),
263
+ source: z.enum(['cloud-link', 'heartbeat']).describe('Which signal this reading came from.'),
264
+ })
265
+ .describe('How reachable a seat is right now, and where that re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F,0CAA0C;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC;KACpC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;KACxD,QAAQ,CAAC,2CAA2C,CAAC,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAC7C,eAAe,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAC1C,2EAA2E,CAC5E,CAAC;AAEF,yCAAyC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;KACnD,QAAQ,CAAC,oCAAoC,CAAC,CAAC;AAElD,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,mBAAmB;IAC1B,UAAU,EAAE,eAAe,CAAC,QAAQ,EAAE;IACtC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC;CAC7F,CAAC;KACD,QAAQ,CAAC,sEAAsE,CAAC,CAAC"}
@@ -0,0 +1,135 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The scopes a bearer token can carry.
4
+ *
5
+ * Mechanism, not catalog: a scope names an ability the protocol defines, and no
6
+ * subscription is inferable from the set.
7
+ */
8
+ export declare const ScopeSchema: z.ZodEnum<{
9
+ "account:read": "account:read";
10
+ "account:write": "account:write";
11
+ "instances:read": "instances:read";
12
+ "instances:write": "instances:write";
13
+ "connections:read": "connections:read";
14
+ "connections:write": "connections:write";
15
+ "billing:read": "billing:read";
16
+ "billing:write": "billing:write";
17
+ "seats:read": "seats:read";
18
+ "seats:write": "seats:write";
19
+ "inference:mint": "inference:mint";
20
+ "remote:read": "remote:read";
21
+ "remote:write": "remote:write";
22
+ }>;
23
+ /** An ability a bearer token carries. */
24
+ export type Scope = z.infer<typeof ScopeSchema>;
25
+ /** The account a token or cookie resolves to. */
26
+ export declare const AccountSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ email: z.ZodString;
29
+ displayName: z.ZodString;
30
+ avatarUrl: z.ZodOptional<z.ZodString>;
31
+ createdAt: z.ZodISODateTime;
32
+ }, z.core.$strip>;
33
+ /** The person behind a token or cookie. */
34
+ export type Account = z.infer<typeof AccountSchema>;
35
+ /** `GET /v1/session` — introspection of the presented token or cookie. */
36
+ export declare const SessionSchema: z.ZodObject<{
37
+ authenticated: z.ZodBoolean;
38
+ account: z.ZodOptional<z.ZodObject<{
39
+ id: z.ZodString;
40
+ email: z.ZodString;
41
+ displayName: z.ZodString;
42
+ avatarUrl: z.ZodOptional<z.ZodString>;
43
+ createdAt: z.ZodISODateTime;
44
+ }, z.core.$strip>>;
45
+ instanceId: z.ZodOptional<z.ZodString>;
46
+ orgId: z.ZodOptional<z.ZodString>;
47
+ seatId: z.ZodOptional<z.ZodString>;
48
+ scopes: z.ZodArray<z.ZodEnum<{
49
+ "account:read": "account:read";
50
+ "account:write": "account:write";
51
+ "instances:read": "instances:read";
52
+ "instances:write": "instances:write";
53
+ "connections:read": "connections:read";
54
+ "connections:write": "connections:write";
55
+ "billing:read": "billing:read";
56
+ "billing:write": "billing:write";
57
+ "seats:read": "seats:read";
58
+ "seats:write": "seats:write";
59
+ "inference:mint": "inference:mint";
60
+ "remote:read": "remote:read";
61
+ "remote:write": "remote:write";
62
+ }>>;
63
+ expiresAt: z.ZodOptional<z.ZodISODateTime>;
64
+ }, z.core.$strip>;
65
+ /** What the presented credential resolves to. */
66
+ export type Session = z.infer<typeof SessionSchema>;
67
+ /** `POST /v1/account/export` — a request for a copy of everything the account holds. */
68
+ export declare const AccountExportRequestSchema: z.ZodObject<{
69
+ notifyEmail: z.ZodOptional<z.ZodBoolean>;
70
+ }, z.core.$strip>;
71
+ /** The accepted export job. */
72
+ export declare const AccountExportResponseSchema: z.ZodObject<{
73
+ exportId: z.ZodString;
74
+ requestedAt: z.ZodISODateTime;
75
+ readyAt: z.ZodNullable<z.ZodISODateTime>;
76
+ downloadUrl: z.ZodNullable<z.ZodString>;
77
+ }, z.core.$strip>;
78
+ /** The state of an account export. */
79
+ export type AccountExport = z.infer<typeof AccountExportResponseSchema>;
80
+ /**
81
+ * `POST /v1/device/code` — the device-authorization request of RFC 8628.
82
+ *
83
+ * One of the two unauthenticated routes in this contract; the other is the
84
+ * token poll below.
85
+ */
86
+ export declare const DeviceCodeRequestSchema: z.ZodObject<{
87
+ clientId: z.ZodString;
88
+ scope: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strip>;
90
+ /**
91
+ * The device-authorization response of RFC 8628.
92
+ *
93
+ * Field names are snake_case here and only here: RFC 8628 fixes them on the
94
+ * wire, and renaming them would make this contract describe something other
95
+ * than the standard it implements.
96
+ */
97
+ export declare const DeviceCodeResponseSchema: z.ZodObject<{
98
+ device_code: z.ZodString;
99
+ user_code: z.ZodString;
100
+ verification_uri: z.ZodString;
101
+ verification_uri_complete: z.ZodOptional<z.ZodString>;
102
+ expires_in: z.ZodNumber;
103
+ interval: z.ZodNumber;
104
+ }, z.core.$strip>;
105
+ /** `POST /v1/device/token` — the token poll of RFC 8628. */
106
+ export declare const DeviceTokenRequestSchema: z.ZodObject<{
107
+ clientId: z.ZodString;
108
+ device_code: z.ZodString;
109
+ grant_type: z.ZodLiteral<"urn:ietf:params:oauth:grant-type:device_code">;
110
+ }, z.core.$strip>;
111
+ /** The granted token pair. */
112
+ export declare const DeviceTokenResponseSchema: z.ZodObject<{
113
+ access_token: z.ZodString;
114
+ token_type: z.ZodLiteral<"Bearer">;
115
+ expires_in: z.ZodNumber;
116
+ refresh_token: z.ZodOptional<z.ZodString>;
117
+ scope: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>;
119
+ /**
120
+ * The pending-state errors RFC 8628 defines for the token poll.
121
+ *
122
+ * Mechanism, and fixed by the RFC rather than by us.
123
+ */
124
+ export declare const DeviceTokenErrorSchema: z.ZodObject<{
125
+ error: z.ZodEnum<{
126
+ expired_token: "expired_token";
127
+ authorization_pending: "authorization_pending";
128
+ slow_down: "slow_down";
129
+ access_denied: "access_denied";
130
+ }>;
131
+ error_description: z.ZodOptional<z.ZodString>;
132
+ }, z.core.$strip>;
133
+ /** The RFC 8628 token-poll error set. */
134
+ export type DeviceTokenError = z.infer<typeof DeviceTokenErrorSchema>;
135
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;EAgB2E,CAAC;AAEpG,yCAAyC;AACzC,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEhD,iDAAiD;AACjD,eAAO,MAAM,aAAa;;;;;;iBAQyB,CAAC;AAEpD,2CAA2C;AAC3C,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,0EAA0E;AAC1E,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkBvB,CAAC;AAEJ,iDAAiD;AACjD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,wFAAwF;AACxF,eAAO,MAAM,0BAA0B;;iBAOsC,CAAC;AAE9E,+BAA+B;AAC/B,eAAO,MAAM,2BAA2B;;;;;iBAW2B,CAAC;AAEpE,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;iBAQmD,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;;iBAmBwD,CAAC;AAE9F,4DAA4D;AAC5D,eAAO,MAAM,wBAAwB;;;;iBAQgC,CAAC;AAEtE,8BAA8B;AAC9B,eAAO,MAAM,yBAAyB;;;;;;iBAQgD,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;iBAOhC,CAAC;AAEJ,yCAAyC;AACzC,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,143 @@
1
+ import { z } from 'zod';
2
+ import { IdSchema, SecretValueSchema, TimestampSchema } from './primitives.js';
3
+ /**
4
+ * The scopes a bearer token can carry.
5
+ *
6
+ * Mechanism, not catalog: a scope names an ability the protocol defines, and no
7
+ * subscription is inferable from the set.
8
+ */
9
+ export const ScopeSchema = z
10
+ .enum([
11
+ 'account:read',
12
+ 'account:write',
13
+ 'instances:read',
14
+ 'instances:write',
15
+ 'connections:read',
16
+ 'connections:write',
17
+ 'billing:read',
18
+ 'billing:write',
19
+ 'seats:read',
20
+ 'seats:write',
21
+ 'inference:mint',
22
+ 'remote:read',
23
+ 'remote:write',
24
+ ])
25
+ .describe('An ability a bearer token carries. Scopes describe the protocol, not a subscription.');
26
+ /** The account a token or cookie resolves to. */
27
+ export const AccountSchema = z
28
+ .object({
29
+ id: IdSchema,
30
+ email: z.string().describe("The account's primary email address."),
31
+ displayName: z.string().describe('The name to show for this account.'),
32
+ avatarUrl: z.string().url().optional().describe("A URL for the account's avatar image."),
33
+ createdAt: TimestampSchema,
34
+ })
35
+ .describe('The person behind a token or cookie.');
36
+ /** `GET /v1/session` — introspection of the presented token or cookie. */
37
+ export const SessionSchema = z
38
+ .object({
39
+ authenticated: z
40
+ .boolean()
41
+ .describe('False when the credential is absent or unusable; every other field is then omitted.'),
42
+ account: AccountSchema.optional(),
43
+ instanceId: IdSchema.optional().describe('The instance this credential was issued to, when it was issued to one rather than to a person.'),
44
+ orgId: IdSchema.optional().describe('The organization this credential is scoped to.'),
45
+ seatId: IdSchema.optional().describe('The seat this credential is scoped to.'),
46
+ scopes: z.array(ScopeSchema).describe('Every scope this credential carries.'),
47
+ expiresAt: TimestampSchema.optional(),
48
+ })
49
+ .describe('What the presented credential resolves to. Unauthenticated is a normal answer, not an error.');
50
+ /** `POST /v1/account/export` — a request for a copy of everything the account holds. */
51
+ export const AccountExportRequestSchema = z
52
+ .object({
53
+ notifyEmail: z
54
+ .boolean()
55
+ .optional()
56
+ .describe('Email the account when the export is ready. Defaults to the server policy.'),
57
+ })
58
+ .describe('A request for a copy of everything the caller`s account holds.');
59
+ /** The accepted export job. */
60
+ export const AccountExportResponseSchema = z
61
+ .object({
62
+ exportId: IdSchema,
63
+ requestedAt: TimestampSchema,
64
+ readyAt: TimestampSchema.nullable().describe('Null while the export is still being assembled.'),
65
+ downloadUrl: z
66
+ .string()
67
+ .url()
68
+ .nullable()
69
+ .describe('A short-lived download link, null until the export is ready.'),
70
+ })
71
+ .describe('The state of an account export the caller asked for.');
72
+ /**
73
+ * `POST /v1/device/code` — the device-authorization request of RFC 8628.
74
+ *
75
+ * One of the two unauthenticated routes in this contract; the other is the
76
+ * token poll below.
77
+ */
78
+ export const DeviceCodeRequestSchema = z
79
+ .object({
80
+ clientId: z.string().min(1).describe('The public client identifier of the program asking.'),
81
+ scope: z
82
+ .string()
83
+ .optional()
84
+ .describe('A space-delimited scope request, as RFC 8628 spells it.'),
85
+ })
86
+ .describe('The device-authorization request of RFC 8628. Unauthenticated by design.');
87
+ /**
88
+ * The device-authorization response of RFC 8628.
89
+ *
90
+ * Field names are snake_case here and only here: RFC 8628 fixes them on the
91
+ * wire, and renaming them would make this contract describe something other
92
+ * than the standard it implements.
93
+ */
94
+ export const DeviceCodeResponseSchema = z
95
+ .object({
96
+ device_code: SecretValueSchema.describe('The device verification code. A credential: it is what the poll below exchanges for a token.'),
97
+ user_code: z.string().describe('The short code the person types into the verification page.'),
98
+ verification_uri: z.string().url().describe('The page the person opens to approve the device.'),
99
+ verification_uri_complete: z
100
+ .string()
101
+ .url()
102
+ .optional()
103
+ .describe('The verification page with the user code already filled in.'),
104
+ expires_in: z.number().int().positive().describe('Seconds until the device code expires.'),
105
+ interval: z
106
+ .number()
107
+ .int()
108
+ .positive()
109
+ .describe('Seconds to wait between polls of the token endpoint.'),
110
+ })
111
+ .describe('The device-authorization response of RFC 8628, with the RFC`s own field names.');
112
+ /** `POST /v1/device/token` — the token poll of RFC 8628. */
113
+ export const DeviceTokenRequestSchema = z
114
+ .object({
115
+ clientId: z.string().min(1),
116
+ device_code: SecretValueSchema,
117
+ grant_type: z
118
+ .literal('urn:ietf:params:oauth:grant-type:device_code')
119
+ .describe('Fixed by RFC 8628.'),
120
+ })
121
+ .describe('The token poll of RFC 8628. Unauthenticated by design.');
122
+ /** The granted token pair. */
123
+ export const DeviceTokenResponseSchema = z
124
+ .object({
125
+ access_token: SecretValueSchema,
126
+ token_type: z.literal('Bearer'),
127
+ expires_in: z.number().int().positive().describe('Seconds until the access token expires.'),
128
+ refresh_token: SecretValueSchema.optional(),
129
+ scope: z.string().optional().describe('The space-delimited scopes actually granted.'),
130
+ })
131
+ .describe('The token pair RFC 8628 grants once the person has approved the device.');
132
+ /**
133
+ * The pending-state errors RFC 8628 defines for the token poll.
134
+ *
135
+ * Mechanism, and fixed by the RFC rather than by us.
136
+ */
137
+ export const DeviceTokenErrorSchema = z
138
+ .object({
139
+ error: z.enum(['authorization_pending', 'slow_down', 'expired_token', 'access_denied']),
140
+ error_description: z.string().optional(),
141
+ })
142
+ .describe('The RFC 8628 token-poll error set. `authorization_pending` and `slow_down` mean keep polling.');
143
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":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CAAC;IAC3F,aAAa,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;CACtF,CAAC;KACD,QAAQ,CAAC,yEAAyE,CAAC,CAAC;AAEvF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC;KACpC,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;IACvF,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACzC,CAAC;KACD,QAAQ,CACP,+FAA+F,CAChG,CAAC"}
@@ -0,0 +1,16 @@
1
+ {
2
+ "allowance": {
3
+ "grantedMicro": "5000000",
4
+ "remainingMicro": "0",
5
+ "resetsAt": "2026-10-15T12:00:00.000Z"
6
+ },
7
+ "purchased": {
8
+ "remainingMicro": "0"
9
+ },
10
+ "heldMicro": "0",
11
+ "owedMicro": "31427",
12
+ "autoReload": {
13
+ "enabled": true,
14
+ "ceilingMicro": "20000000"
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "allowance": {
3
+ "grantedMicro": "5000000",
4
+ "remainingMicro": "1250000",
5
+ "resetsAt": "2026-10-15T12:00:00.000Z"
6
+ },
7
+ "purchased": {
8
+ "remainingMicro": "0"
9
+ },
10
+ "heldMicro": "25000",
11
+ "owedMicro": "0",
12
+ "autoReload": {
13
+ "enabled": false,
14
+ "ceilingMicro": null
15
+ }
16
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "planId": "pl_opaque_0000",
3
+ "planDisplayName": "the entitlement shown in your billing page",
4
+ "periodStart": "2026-09-15T12:00:00.000Z",
5
+ "periodEnd": "2026-10-15T12:00:00.000Z",
6
+ "limits": {
7
+ "personSeatsIncluded": 1,
8
+ "agentSeatsIncluded": 0,
9
+ "includedCreditsMicro": "0",
10
+ "cloudHours": 0,
11
+ "storageGb": 1,
12
+ "remoteAccess": "byo",
13
+ "alwaysAvailableInstances": 0,
14
+ "customAddress": "none",
15
+ "managedConnectionActions": null,
16
+ "support": "community",
17
+ "emailAddressPerSeat": false
18
+ },
19
+ "used": {
20
+ "personSeats": 1,
21
+ "agentSeats": 0
22
+ },
23
+ "seats": {
24
+ "total": 1,
25
+ "assigned": 1,
26
+ "byKind": {
27
+ "person": 1,
28
+ "agent": 0
29
+ }
30
+ },
31
+ "canCreateSeat": false,
32
+ "canInviteMember": false,
33
+ "staleAt": "2026-10-15T12:00:00.000Z"
34
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "url": "https://example.invalid/hosted/checkout/abc123"
3
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "trailing30Micro": "48000000",
3
+ "suggestedPlanId": "pl_opaque_0002",
4
+ "suggestedPlanDisplayName": "the subscription shown in your billing page",
5
+ "suggestedPlanPriceMicro": "20000000",
6
+ "savingMicro": "28000000",
7
+ "computedAt": "2026-09-15T12:00:00.000Z",
8
+ "dismissible": true
9
+ }