@stigmer/sdk 3.2.3 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/__tests__/errors.test.js +44 -1
  2. package/__tests__/errors.test.js.map +1 -1
  3. package/__tests__/manifest.test.d.ts +2 -0
  4. package/__tests__/manifest.test.d.ts.map +1 -0
  5. package/__tests__/manifest.test.js +229 -0
  6. package/__tests__/manifest.test.js.map +1 -0
  7. package/__tests__/session.test.d.ts +6 -0
  8. package/__tests__/session.test.d.ts.map +1 -0
  9. package/__tests__/session.test.js +50 -0
  10. package/__tests__/session.test.js.map +1 -0
  11. package/billing.d.ts +83 -1
  12. package/billing.d.ts.map +1 -1
  13. package/billing.js +91 -1
  14. package/billing.js.map +1 -1
  15. package/cursor-accounts.d.ts +94 -0
  16. package/cursor-accounts.d.ts.map +1 -0
  17. package/cursor-accounts.js +119 -0
  18. package/cursor-accounts.js.map +1 -0
  19. package/errors.d.ts +14 -0
  20. package/errors.d.ts.map +1 -1
  21. package/errors.js +26 -0
  22. package/errors.js.map +1 -1
  23. package/gen/agent.d.ts +5 -0
  24. package/gen/agent.d.ts.map +1 -1
  25. package/gen/agent.js +9 -1
  26. package/gen/agent.js.map +1 -1
  27. package/gen/agentexecution.d.ts +1 -0
  28. package/gen/agentexecution.d.ts.map +1 -1
  29. package/gen/agentexecution.js +2 -0
  30. package/gen/agentexecution.js.map +1 -1
  31. package/gen/agentinstance.d.ts +1 -0
  32. package/gen/agentinstance.d.ts.map +1 -1
  33. package/gen/agentinstance.js +1 -0
  34. package/gen/agentinstance.js.map +1 -1
  35. package/gen/authorization-config.d.ts.map +1 -1
  36. package/gen/authorization-config.js +1 -0
  37. package/gen/authorization-config.js.map +1 -1
  38. package/gen/client.d.ts +6 -2
  39. package/gen/client.d.ts.map +1 -1
  40. package/gen/client.js +4 -0
  41. package/gen/client.js.map +1 -1
  42. package/gen/datastore.d.ts +129 -0
  43. package/gen/datastore.d.ts.map +1 -0
  44. package/gen/datastore.js +303 -0
  45. package/gen/datastore.js.map +1 -0
  46. package/gen/session.d.ts +1 -0
  47. package/gen/session.d.ts.map +1 -1
  48. package/gen/session.js +1 -0
  49. package/gen/session.js.map +1 -1
  50. package/index.d.ts +6 -4
  51. package/index.d.ts.map +1 -1
  52. package/index.js +8 -4
  53. package/index.js.map +1 -1
  54. package/manifest/client.d.ts +64 -0
  55. package/manifest/client.d.ts.map +1 -0
  56. package/manifest/client.js +109 -0
  57. package/manifest/client.js.map +1 -0
  58. package/manifest/index.d.ts +9 -0
  59. package/manifest/index.d.ts.map +1 -0
  60. package/manifest/index.js +11 -0
  61. package/manifest/index.js.map +1 -0
  62. package/manifest/parse.d.ts +57 -0
  63. package/manifest/parse.d.ts.map +1 -0
  64. package/manifest/parse.js +134 -0
  65. package/manifest/parse.js.map +1 -0
  66. package/manifest/redaction.d.ts +16 -0
  67. package/manifest/redaction.d.ts.map +1 -0
  68. package/manifest/redaction.js +19 -0
  69. package/manifest/redaction.js.map +1 -0
  70. package/manifest/registry.d.ts +44 -0
  71. package/manifest/registry.d.ts.map +1 -0
  72. package/manifest/registry.js +178 -0
  73. package/manifest/registry.js.map +1 -0
  74. package/manifest/serialize.d.ts +24 -0
  75. package/manifest/serialize.d.ts.map +1 -0
  76. package/manifest/serialize.js +78 -0
  77. package/manifest/serialize.js.map +1 -0
  78. package/package.json +4 -3
  79. package/session.d.ts +37 -0
  80. package/session.d.ts.map +1 -1
  81. package/session.js +43 -0
  82. package/session.js.map +1 -1
  83. package/src/__tests__/errors.test.ts +58 -0
  84. package/src/__tests__/manifest.test.ts +271 -0
  85. package/src/__tests__/session.test.ts +66 -0
  86. package/src/billing.ts +160 -0
  87. package/src/cursor-accounts.ts +207 -0
  88. package/src/errors.ts +27 -0
  89. package/src/gen/agent.ts +15 -1
  90. package/src/gen/agentexecution.ts +2 -0
  91. package/src/gen/agentinstance.ts +2 -0
  92. package/src/gen/authorization-config.ts +1 -0
  93. package/src/gen/client.ts +7 -2
  94. package/src/gen/datastore.ts +381 -0
  95. package/src/gen/session.ts +2 -0
  96. package/src/index.ts +36 -1
  97. package/src/manifest/client.ts +145 -0
  98. package/src/manifest/index.ts +25 -0
  99. package/src/manifest/parse.ts +204 -0
  100. package/src/manifest/redaction.ts +20 -0
  101. package/src/manifest/registry.ts +232 -0
  102. package/src/manifest/serialize.ts +92 -0
  103. package/src/session.ts +48 -0
  104. package/src/stigmer.ts +8 -0
  105. package/stigmer.d.ts +6 -0
  106. package/stigmer.d.ts.map +1 -1
  107. package/stigmer.js +8 -0
  108. package/stigmer.js.map +1 -1
@@ -0,0 +1,381 @@
1
+ // Code generated by stigmer-codegen. DO NOT EDIT.
2
+
3
+ import { wrapError } from "./errors.js";
4
+ import { stripUndefined } from "./proto-utils.js";
5
+ import { type DeleteResourceInput, type ListParams, type ListResult, type ResourceRef } from "./types.js";
6
+ import { create, fromJson, type JsonValue } from "@bufbuild/protobuf";
7
+ import { ValueSchema } from "@bufbuild/protobuf/wkt";
8
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
9
+ import { DatastoreSchema, type Datastore } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/api_pb";
10
+ import { DatastoreCommandController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/command_pb";
11
+ import { DatastoreQueryController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/query_pb";
12
+ import { DatastoreRecordCommandController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/record_command_pb";
13
+ import { InsertRecordRequestSchema, RecordEnvelopeSchema, UpdateRecordRequestSchema, DeleteRecordRequestSchema, FindRecordsRequestSchema, RecordListSchema, DescribeDatastoreRequestSchema, DatastoreDescriptionSchema, type InsertRecordRequest, type RecordEnvelope, type UpdateRecordRequest, type DeleteRecordRequest, type FindRecordsRequest, type RecordList, type DescribeDatastoreRequest, type DatastoreDescription } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/record_io_pb";
14
+ import { DatastoreRecordQueryController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/record_query_pb";
15
+ import { DatastoreSpecSchema, FieldType, DatastoreVerb, DatastoreGrantScope, DatastoreRoleSchema, ChannelSenderSubjectSchema, DatastoreSubjectSchema, DatastoreRoleBindingSchema, DatastoreAuthorizationSchema, FieldDeclarationSchema, UniqueWhereSchema, UniqueConstraintSchema, CheckConstraintSchema, ExistsConstraintSchema, DatastoreGrantSchema, CollectionDeclarationSchema } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/spec_pb";
16
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
17
+ import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
18
+ import { ApiResourceIdSchema, ApiResourceReferenceSchema, ApiResourceDeleteInputSchema, type UpdateVisibilityInput } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
19
+ import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
20
+ import { PageInfoSchema } from "@stigmer/protos/ai/stigmer/commons/rpc/pagination_pb";
21
+ import { ApiResourceRefSchema } from "@stigmer/protos/ai/stigmer/iam/iampolicy/v1/spec_pb";
22
+ import { SearchRequestSchema } from "@stigmer/protos/ai/stigmer/search/v1/io_pb";
23
+ import { SearchService } from "@stigmer/protos/ai/stigmer/search/v1/query_pb";
24
+
25
+ /** Provides operations on datastore resources. */
26
+ export class DatastoreClient {
27
+ private readonly command: Client<typeof DatastoreCommandController>;
28
+ private readonly query: Client<typeof DatastoreQueryController>;
29
+ private readonly datastoreRecordCommand: Client<typeof DatastoreRecordCommandController>;
30
+ private readonly datastoreRecordQuery: Client<typeof DatastoreRecordQueryController>;
31
+ private readonly search: Client<typeof SearchService>;
32
+
33
+ constructor(transport: Transport) {
34
+ this.command = createClient(DatastoreCommandController, transport);
35
+ this.query = createClient(DatastoreQueryController, transport);
36
+ this.datastoreRecordCommand = createClient(DatastoreRecordCommandController, transport);
37
+ this.datastoreRecordQuery = createClient(DatastoreRecordQueryController, transport);
38
+ this.search = createClient(SearchService, transport);
39
+ }
40
+
41
+ async apply(input: DatastoreInput): Promise<Datastore> {
42
+ try {
43
+ return await this.command.apply(buildDatastoreProto(input));
44
+ } catch (e) { throw wrapError(e); }
45
+ }
46
+
47
+ async create(input: DatastoreInput): Promise<Datastore> {
48
+ try {
49
+ return await this.command.create(buildDatastoreProto(input));
50
+ } catch (e) { throw wrapError(e); }
51
+ }
52
+
53
+ async update(input: DatastoreInput): Promise<Datastore> {
54
+ try {
55
+ return await this.command.update(buildDatastoreProto(input));
56
+ } catch (e) { throw wrapError(e); }
57
+ }
58
+
59
+ async updateVisibility(input: UpdateVisibilityInput): Promise<Datastore> {
60
+ try {
61
+ return await this.command.updateVisibility(input);
62
+ } catch (e) { throw wrapError(e); }
63
+ }
64
+
65
+ async delete(input: DeleteResourceInput): Promise<Datastore> {
66
+ try {
67
+ return await this.command.delete(create(ApiResourceDeleteInputSchema, {
68
+ resourceId: input.resourceId,
69
+ versionMessage: input.versionMessage,
70
+ force: input.force,
71
+ }));
72
+ } catch (e) { throw wrapError(e); }
73
+ }
74
+
75
+ async get(id: string): Promise<Datastore> {
76
+ try {
77
+ return await this.query.get(create(ApiResourceIdSchema, { value: id }));
78
+ } catch (e) { throw wrapError(e); }
79
+ }
80
+
81
+ async getByReference(ref: ResourceRef): Promise<Datastore> {
82
+ try {
83
+ return await this.query.getByReference(create(ApiResourceReferenceSchema, { ...ref, kind: ApiResourceKind.datastore }));
84
+ } catch (e) { throw wrapError(e); }
85
+ }
86
+
87
+ async insertRecord(input: InsertRecordRequest): Promise<RecordEnvelope> {
88
+ try {
89
+ return await this.datastoreRecordCommand.insertRecord(input);
90
+ } catch (e) { throw wrapError(e); }
91
+ }
92
+
93
+ async updateRecord(input: UpdateRecordRequest): Promise<RecordEnvelope> {
94
+ try {
95
+ return await this.datastoreRecordCommand.updateRecord(input);
96
+ } catch (e) { throw wrapError(e); }
97
+ }
98
+
99
+ async deleteRecord(input: DeleteRecordRequest): Promise<RecordEnvelope> {
100
+ try {
101
+ return await this.datastoreRecordCommand.deleteRecord(input);
102
+ } catch (e) { throw wrapError(e); }
103
+ }
104
+
105
+ async findRecords(input: FindRecordsRequest): Promise<RecordList> {
106
+ try {
107
+ return await this.datastoreRecordQuery.findRecords(input);
108
+ } catch (e) { throw wrapError(e); }
109
+ }
110
+
111
+ async describeDatastore(input: DescribeDatastoreRequest): Promise<DatastoreDescription> {
112
+ try {
113
+ return await this.datastoreRecordQuery.describeDatastore(input);
114
+ } catch (e) { throw wrapError(e); }
115
+ }
116
+
117
+ async list(params: ListParams): Promise<ListResult> {
118
+ try {
119
+ const resp = await this.search.search(create(SearchRequestSchema, {
120
+ kinds: [ApiResourceKind.datastore],
121
+ query: params.query,
122
+ org: params.org,
123
+ excludePublic: params.excludePublic ?? false,
124
+ crossOrgPublic: params.crossOrgPublic ?? false,
125
+ page: params.page ? create(PageInfoSchema, params.page) : undefined,
126
+ }));
127
+ return {
128
+ entries: resp.entries,
129
+ totalCount: resp.totalCount,
130
+ totalPages: resp.totalPages,
131
+ };
132
+ } catch (e) { throw wrapError(e); }
133
+ }
134
+ }
135
+
136
+ /** Input for creating/updating a Datastore. */
137
+ export interface DatastoreInput {
138
+ name: string;
139
+ slug?: string;
140
+ org: string;
141
+ labels?: Record<string, string>;
142
+ visibility?: ApiResourceVisibility;
143
+ description?: string;
144
+ timezone?: string;
145
+ authorization?: DatastoreAuthorizationInput;
146
+ collections?: CollectionDeclarationInput[];
147
+ }
148
+
149
+ /** SDK input type for DatastoreAuthorization. */
150
+ export interface DatastoreAuthorizationInput {
151
+ roles?: DatastoreRoleInput[];
152
+ bindings?: DatastoreRoleBindingInput[];
153
+ defaultRole?: string;
154
+ }
155
+
156
+ /** SDK input type for DatastoreRole. */
157
+ export interface DatastoreRoleInput {
158
+ name: string;
159
+ }
160
+
161
+ /** SDK input type for DatastoreRoleBinding. */
162
+ export interface DatastoreRoleBindingInput {
163
+ subject: DatastoreSubjectInput;
164
+ role: string;
165
+ }
166
+
167
+ /** SDK input type for DatastoreSubject. */
168
+ export interface DatastoreSubjectInput {
169
+ channelSender?: ChannelSenderSubjectInput;
170
+ principal?: ApiResourceRefInput;
171
+ }
172
+
173
+ /** SDK input type for ChannelSenderSubject. */
174
+ export interface ChannelSenderSubjectInput {
175
+ senderKind: string;
176
+ value: string;
177
+ }
178
+
179
+ /** SDK input type for ApiResourceRef. */
180
+ export interface ApiResourceRefInput {
181
+ kind: string;
182
+ id: string;
183
+ relation?: string;
184
+ }
185
+
186
+ /** SDK input type for CollectionDeclaration. */
187
+ export interface CollectionDeclarationInput {
188
+ name: string;
189
+ description?: string;
190
+ fields?: FieldDeclarationInput[];
191
+ uniques?: UniqueConstraintInput[];
192
+ checks?: CheckConstraintInput[];
193
+ exists?: ExistsConstraintInput[];
194
+ notExists?: ExistsConstraintInput[];
195
+ grants?: DatastoreGrantInput[];
196
+ }
197
+
198
+ /** SDK input type for FieldDeclaration. */
199
+ export interface FieldDeclarationInput {
200
+ name: string;
201
+ type: FieldType;
202
+ required?: boolean;
203
+ default?: JsonValue;
204
+ enumValues?: string[];
205
+ description?: string;
206
+ }
207
+
208
+ /** SDK input type for UniqueConstraint. */
209
+ export interface UniqueConstraintInput {
210
+ name: string;
211
+ fields?: string[];
212
+ where?: UniqueWhereInput;
213
+ message: string;
214
+ }
215
+
216
+ /** SDK input type for UniqueWhere. */
217
+ export interface UniqueWhereInput {
218
+ field: string;
219
+ equals: JsonValue;
220
+ }
221
+
222
+ /** SDK input type for CheckConstraint. */
223
+ export interface CheckConstraintInput {
224
+ name: string;
225
+ expression: string;
226
+ when?: string;
227
+ message: string;
228
+ }
229
+
230
+ /** SDK input type for ExistsConstraint. */
231
+ export interface ExistsConstraintInput {
232
+ name: string;
233
+ collection: string;
234
+ where: string;
235
+ when?: string;
236
+ message: string;
237
+ }
238
+
239
+ /** SDK input type for DatastoreGrant. */
240
+ export interface DatastoreGrantInput {
241
+ role: string;
242
+ verbs?: DatastoreVerb[];
243
+ scope?: DatastoreGrantScope;
244
+ readFields?: string[];
245
+ }
246
+
247
+ function buildDatastoreRoleProto(input: DatastoreRoleInput) {
248
+ return Object.assign(create(DatastoreRoleSchema), stripUndefined({
249
+ name: input.name,
250
+ }));
251
+ }
252
+
253
+ function buildChannelSenderSubjectProto(input: ChannelSenderSubjectInput) {
254
+ return Object.assign(create(ChannelSenderSubjectSchema), stripUndefined({
255
+ senderKind: input.senderKind,
256
+ value: input.value,
257
+ }));
258
+ }
259
+
260
+ function buildApiResourceRefProto(input: ApiResourceRefInput) {
261
+ return Object.assign(create(ApiResourceRefSchema), stripUndefined({
262
+ kind: input.kind,
263
+ id: input.id,
264
+ relation: input.relation,
265
+ }));
266
+ }
267
+
268
+ function buildDatastoreSubjectProto(input: DatastoreSubjectInput) {
269
+ const msg = create(DatastoreSubjectSchema);
270
+ if (input.channelSender) {
271
+ msg.kind = { case: "channelSender", value: buildChannelSenderSubjectProto(input.channelSender) };
272
+ } else if (input.principal) {
273
+ msg.kind = { case: "principal", value: buildApiResourceRefProto(input.principal) };
274
+ }
275
+ return msg;
276
+ }
277
+
278
+ function buildDatastoreRoleBindingProto(input: DatastoreRoleBindingInput) {
279
+ const msg = create(DatastoreRoleBindingSchema);
280
+ if (input.subject) msg.subject = buildDatastoreSubjectProto(input.subject);
281
+ if (input.role !== undefined) msg.role = input.role;
282
+ return msg;
283
+ }
284
+
285
+ function buildDatastoreAuthorizationProto(input: DatastoreAuthorizationInput) {
286
+ const msg = create(DatastoreAuthorizationSchema);
287
+ if (input.roles) msg.roles = input.roles.map(buildDatastoreRoleProto);
288
+ if (input.bindings) msg.bindings = input.bindings.map(buildDatastoreRoleBindingProto);
289
+ if (input.defaultRole !== undefined) msg.defaultRole = input.defaultRole;
290
+ return msg;
291
+ }
292
+
293
+ function buildFieldDeclarationProto(input: FieldDeclarationInput) {
294
+ const msg = create(FieldDeclarationSchema);
295
+ if (input.name !== undefined) msg.name = input.name;
296
+ if (input.type !== undefined) msg.type = input.type;
297
+ if (input.required !== undefined) msg.required = input.required;
298
+ if (input.default !== undefined) msg.default = fromJson(ValueSchema, input.default);
299
+ if (input.enumValues) msg.enumValues = input.enumValues;
300
+ if (input.description !== undefined) msg.description = input.description;
301
+ return msg;
302
+ }
303
+
304
+ function buildUniqueWhereProto(input: UniqueWhereInput) {
305
+ const msg = create(UniqueWhereSchema);
306
+ if (input.field !== undefined) msg.field = input.field;
307
+ if (input.equals !== undefined) msg.equals = fromJson(ValueSchema, input.equals);
308
+ return msg;
309
+ }
310
+
311
+ function buildUniqueConstraintProto(input: UniqueConstraintInput) {
312
+ const msg = create(UniqueConstraintSchema);
313
+ if (input.name !== undefined) msg.name = input.name;
314
+ if (input.fields) msg.fields = input.fields;
315
+ if (input.where) msg.where = buildUniqueWhereProto(input.where);
316
+ if (input.message !== undefined) msg.message = input.message;
317
+ return msg;
318
+ }
319
+
320
+ function buildCheckConstraintProto(input: CheckConstraintInput) {
321
+ return Object.assign(create(CheckConstraintSchema), stripUndefined({
322
+ name: input.name,
323
+ expression: input.expression,
324
+ when: input.when,
325
+ message: input.message,
326
+ }));
327
+ }
328
+
329
+ function buildExistsConstraintProto(input: ExistsConstraintInput) {
330
+ return Object.assign(create(ExistsConstraintSchema), stripUndefined({
331
+ name: input.name,
332
+ collection: input.collection,
333
+ where: input.where,
334
+ when: input.when,
335
+ message: input.message,
336
+ }));
337
+ }
338
+
339
+ function buildDatastoreGrantProto(input: DatastoreGrantInput) {
340
+ return Object.assign(create(DatastoreGrantSchema), stripUndefined({
341
+ role: input.role,
342
+ verbs: input.verbs,
343
+ scope: input.scope,
344
+ readFields: input.readFields,
345
+ }));
346
+ }
347
+
348
+ function buildCollectionDeclarationProto(input: CollectionDeclarationInput) {
349
+ const msg = create(CollectionDeclarationSchema);
350
+ if (input.name !== undefined) msg.name = input.name;
351
+ if (input.description !== undefined) msg.description = input.description;
352
+ if (input.fields) msg.fields = input.fields.map(buildFieldDeclarationProto);
353
+ if (input.uniques) msg.uniques = input.uniques.map(buildUniqueConstraintProto);
354
+ if (input.checks) msg.checks = input.checks.map(buildCheckConstraintProto);
355
+ if (input.exists) msg.exists = input.exists.map(buildExistsConstraintProto);
356
+ if (input.notExists) msg.notExists = input.notExists.map(buildExistsConstraintProto);
357
+ if (input.grants) msg.grants = input.grants.map(buildDatastoreGrantProto);
358
+ return msg;
359
+ }
360
+
361
+ export function buildDatastoreProto(input: DatastoreInput): Datastore {
362
+ const authorization = input.authorization ? buildDatastoreAuthorizationProto(input.authorization) : undefined;
363
+ const collections = input.collections?.map(buildCollectionDeclarationProto);
364
+ return Object.assign(create(DatastoreSchema), {
365
+ apiVersion: "agentic.stigmer.ai/v1",
366
+ kind: "Datastore",
367
+ metadata: Object.assign(create(ApiResourceMetadataSchema), {
368
+ name: input.name,
369
+ org: input.org,
370
+ ...(input.slug && { slug: input.slug }),
371
+ ...(input.labels && { labels: input.labels }),
372
+ ...(input.visibility && { visibility: input.visibility }),
373
+ }),
374
+ spec: Object.assign(create(DatastoreSpecSchema), stripUndefined({
375
+ description: input.description,
376
+ timezone: input.timezone,
377
+ authorization,
378
+ collections,
379
+ })),
380
+ }) as Datastore;
381
+ }
@@ -92,6 +92,7 @@ export interface SessionInput {
92
92
  agentInstanceId?: string;
93
93
  subject?: string;
94
94
  harnessStateId?: string;
95
+ harnessStateIdHistory?: string[];
95
96
  metadata?: Record<string, string>;
96
97
  workspaceEntries?: WorkspaceEntryInput[];
97
98
  mcpServerUsages?: McpServerUsageInput[];
@@ -208,6 +209,7 @@ export function buildSessionProto(input: SessionInput): Session {
208
209
  agentInstanceId: input.agentInstanceId,
209
210
  subject: input.subject,
210
211
  harnessStateId: input.harnessStateId,
212
+ harnessStateIdHistory: input.harnessStateIdHistory,
211
213
  metadata: input.metadata,
212
214
  workspaceEntries,
213
215
  mcpServerUsages,
package/src/index.ts CHANGED
@@ -49,6 +49,7 @@ export {
49
49
  getUserMessage,
50
50
  type ErrorReason,
51
51
  getErrorReason,
52
+ getRecordConstraint,
52
53
  type RpcErrorMetadata,
53
54
  annotateRpcError,
54
55
  getRpcMetadata,
@@ -93,6 +94,16 @@ export {
93
94
  type GetCustomerModelPricingParams,
94
95
  } from "./billing.js";
95
96
 
97
+ // Cursor accounts client (platform operators only)
98
+ export {
99
+ CursorAccountsClient,
100
+ type UpsertCursorAccountParams,
101
+ type DeleteCursorAccountParams,
102
+ type AddCursorMemberKeyParams,
103
+ type RemoveCursorMemberKeyParams,
104
+ type SetCursorMemberKeyEnabledParams,
105
+ } from "./cursor-accounts.js";
106
+
96
107
  // Search client
97
108
  export {
98
109
  SearchClient,
@@ -116,6 +127,23 @@ export {
116
127
  type ServerInfo,
117
128
  } from "./platform.js";
118
129
 
130
+ // Manifest engine (kind-agnostic YAML ⇄ proto ⇄ apply)
131
+ export {
132
+ ManifestClient,
133
+ parseManifest,
134
+ serializeManifest,
135
+ manifestKinds,
136
+ manifestHandlerForYamlKind,
137
+ manifestHandlerForTypeName,
138
+ metadataOf,
139
+ REDACTED_SECRET_MARKER,
140
+ containsRedactedSecrets,
141
+ type AppliedManifest,
142
+ type ManifestDocument,
143
+ type ManifestKindHandler,
144
+ type ParseManifestOptions,
145
+ } from "./manifest/index.js";
146
+
119
147
  // Shared types (from generated code)
120
148
  export {
121
149
  type DeleteResourceInput,
@@ -130,6 +158,7 @@ export {
130
158
  // Re-export all resource client classes and input types
131
159
  export {
132
160
  AgentClient,
161
+ buildAgentProto,
133
162
  type AgentInput,
134
163
  type McpServerUsageInput,
135
164
  type ToolApprovalOverrideInput,
@@ -194,6 +223,7 @@ export {
194
223
  } from "./gen/oauthapp.js";
195
224
  export {
196
225
  McpServerClient,
226
+ buildMcpServerProto,
197
227
  type McpServerInput,
198
228
  type StdioServerConfigInput,
199
229
  type HttpServerConfigInput,
@@ -218,7 +248,12 @@ export {
218
248
  } from "./gen/session.js";
219
249
 
220
250
  // Session utilities (hand-written)
221
- export { PENDING_SUBJECT, resolvedSubject } from "./session.js";
251
+ export {
252
+ PENDING_SUBJECT,
253
+ SESSION_CONTEXT_METADATA_KEY,
254
+ mergeSessionContext,
255
+ resolvedSubject,
256
+ } from "./session.js";
222
257
 
223
258
  // Tool-call view model (framework-agnostic; shared by @stigmer/react and @stigmer/ink)
224
259
  export {
@@ -0,0 +1,145 @@
1
+ // Kind-agnostic apply/lookup over the manifest registry.
2
+ //
3
+ // One client, every registry kind: `apply` drives the kind's command
4
+ // controller with the full resource proto (create-or-update by slug,
5
+ // server-side), `getByReference` loads current server state for
6
+ // create-vs-update previews and YAML editing.
7
+
8
+ import type { Message } from "@bufbuild/protobuf";
9
+ import { create } from "@bufbuild/protobuf";
10
+ import type { DescService } from "@bufbuild/protobuf";
11
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
12
+ import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
13
+ import { wrapError } from "../gen/errors.js";
14
+ import { metadataOf, type ManifestDocument } from "./parse.js";
15
+ import {
16
+ manifestHandlerForYamlKind,
17
+ manifestKinds,
18
+ type ManifestKindHandler,
19
+ type ServiceClientFn,
20
+ } from "./registry.js";
21
+
22
+ /** Result of applying one manifest document. */
23
+ export interface AppliedManifest {
24
+ /** The YAML kind that was applied, e.g. `"Agent"`. */
25
+ readonly yamlKind: string;
26
+ /** Human-facing kind name, e.g. `"MCP Server"`. */
27
+ readonly displayName: string;
28
+ /** Server-authoritative resource name. */
29
+ readonly name: string;
30
+ /** Server-authoritative slug (routing key for future applies). */
31
+ readonly slug: string;
32
+ /** Organization the resource lives in. */
33
+ readonly org: string;
34
+ /** Server-assigned resource id. */
35
+ readonly id: string;
36
+ /** The full applied resource, as returned by the server. */
37
+ readonly message: Message;
38
+ }
39
+
40
+ /**
41
+ * Client for applying and loading Stigmer resources as manifests,
42
+ * independent of kind.
43
+ *
44
+ * Complements the typed per-kind clients (`stigmer.agent`, …): those take
45
+ * curated `*Input` shapes for programmatic use; this one takes full
46
+ * resource protos produced by {@link parseManifest} — the declarative
47
+ * "apply this YAML" path, with the same semantics as `stigmer apply -f`.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const docs = parseManifest(yamlText, { org: "acme" });
52
+ * for (const doc of docs) {
53
+ * const applied = await stigmer.manifest.apply(doc);
54
+ * console.log(`${applied.displayName} ${applied.slug} applied`);
55
+ * }
56
+ * ```
57
+ */
58
+ export class ManifestClient {
59
+ // Raw controller clients are created lazily and cached per service —
60
+ // one dialog session typically touches one or two kinds.
61
+ private readonly clients = new Map<DescService, Client<DescService>>();
62
+ private readonly transport: Transport;
63
+ private readonly clientFor: ServiceClientFn;
64
+
65
+ constructor(transport: Transport) {
66
+ this.transport = transport;
67
+ this.clientFor = <Desc extends DescService>(service: Desc): Client<Desc> => {
68
+ let client = this.clients.get(service);
69
+ if (client === undefined) {
70
+ client = createClient(service, this.transport);
71
+ this.clients.set(service, client);
72
+ }
73
+ return client as Client<Desc>;
74
+ };
75
+ }
76
+
77
+ /** The kinds this client can apply, in dependency apply order. */
78
+ supportedKinds(): readonly ManifestKindHandler[] {
79
+ return manifestKinds();
80
+ }
81
+
82
+ /**
83
+ * Apply one parsed manifest document (create-or-update by slug).
84
+ *
85
+ * @throws {StigmerError} When the server rejects the apply
86
+ * (validation, permissions, …).
87
+ */
88
+ async apply(document: ManifestDocument): Promise<AppliedManifest> {
89
+ let applied: Message;
90
+ try {
91
+ applied = await document.handler.apply(this.clientFor, document.message);
92
+ } catch (e) {
93
+ throw wrapError(e);
94
+ }
95
+
96
+ const metadata = metadataOf(applied);
97
+ return {
98
+ yamlKind: document.handler.yamlKind,
99
+ displayName: document.handler.displayName,
100
+ name: metadata?.name || document.name,
101
+ slug: metadata?.slug || document.slug,
102
+ org: metadata?.org || document.org,
103
+ id: metadata?.id ?? "",
104
+ message: applied,
105
+ };
106
+ }
107
+
108
+ /**
109
+ * Load a resource's current server state by kind + org/slug reference.
110
+ *
111
+ * @returns The resource proto, or `null` when it does not exist —
112
+ * the create-vs-update discriminator for previews.
113
+ * @throws {Error} When the kind is not in the manifest registry.
114
+ * @throws {StigmerError} For failures other than not-found.
115
+ */
116
+ async getByReference(
117
+ yamlKind: string,
118
+ org: string,
119
+ slug: string,
120
+ ): Promise<Message | null> {
121
+ const handler = manifestHandlerForYamlKind(yamlKind);
122
+ if (handler === undefined) {
123
+ const supported = manifestKinds()
124
+ .map((h) => h.yamlKind)
125
+ .join(", ");
126
+ throw new Error(
127
+ `Unsupported resource kind "${yamlKind}". Supported kinds: ${supported}.`,
128
+ );
129
+ }
130
+
131
+ const ref = create(ApiResourceReferenceSchema, {
132
+ org,
133
+ slug,
134
+ kind: handler.kind,
135
+ });
136
+
137
+ try {
138
+ return await handler.getByReference(this.clientFor, ref);
139
+ } catch (e) {
140
+ const wrapped = wrapError(e);
141
+ if (wrapped.code === "not-found") return null;
142
+ throw wrapped;
143
+ }
144
+ }
145
+ }
@@ -0,0 +1,25 @@
1
+ // Manifest engine: kind-agnostic YAML ⇄ proto ⇄ apply for Stigmer resources.
2
+ //
3
+ // The declarative counterpart to the typed per-kind clients — parse a YAML
4
+ // manifest against generated proto schemas, serialize server state back to
5
+ // editable YAML, and apply through each kind's command controller.
6
+
7
+ export {
8
+ manifestKinds,
9
+ manifestHandlerForYamlKind,
10
+ manifestHandlerForTypeName,
11
+ } from "./registry.js";
12
+ export type { ManifestKindHandler, ServiceClientFn } from "./registry.js";
13
+
14
+ export { parseManifest, metadataOf } from "./parse.js";
15
+ export type { ManifestDocument, ParseManifestOptions } from "./parse.js";
16
+
17
+ export { serializeManifest } from "./serialize.js";
18
+
19
+ export { ManifestClient } from "./client.js";
20
+ export type { AppliedManifest } from "./client.js";
21
+
22
+ export {
23
+ REDACTED_SECRET_MARKER,
24
+ containsRedactedSecrets,
25
+ } from "./redaction.js";