@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.
- package/__tests__/errors.test.js +44 -1
- package/__tests__/errors.test.js.map +1 -1
- package/__tests__/manifest.test.d.ts +2 -0
- package/__tests__/manifest.test.d.ts.map +1 -0
- package/__tests__/manifest.test.js +229 -0
- package/__tests__/manifest.test.js.map +1 -0
- package/__tests__/session.test.d.ts +6 -0
- package/__tests__/session.test.d.ts.map +1 -0
- package/__tests__/session.test.js +50 -0
- package/__tests__/session.test.js.map +1 -0
- package/billing.d.ts +83 -1
- package/billing.d.ts.map +1 -1
- package/billing.js +91 -1
- package/billing.js.map +1 -1
- package/cursor-accounts.d.ts +94 -0
- package/cursor-accounts.d.ts.map +1 -0
- package/cursor-accounts.js +119 -0
- package/cursor-accounts.js.map +1 -0
- package/errors.d.ts +14 -0
- package/errors.d.ts.map +1 -1
- package/errors.js +26 -0
- package/errors.js.map +1 -1
- package/gen/agent.d.ts +5 -0
- package/gen/agent.d.ts.map +1 -1
- package/gen/agent.js +9 -1
- package/gen/agent.js.map +1 -1
- package/gen/agentexecution.d.ts +1 -0
- package/gen/agentexecution.d.ts.map +1 -1
- package/gen/agentexecution.js +2 -0
- package/gen/agentexecution.js.map +1 -1
- package/gen/agentinstance.d.ts +1 -0
- package/gen/agentinstance.d.ts.map +1 -1
- package/gen/agentinstance.js +1 -0
- package/gen/agentinstance.js.map +1 -1
- package/gen/authorization-config.d.ts.map +1 -1
- package/gen/authorization-config.js +1 -0
- package/gen/authorization-config.js.map +1 -1
- package/gen/client.d.ts +6 -2
- package/gen/client.d.ts.map +1 -1
- package/gen/client.js +4 -0
- package/gen/client.js.map +1 -1
- package/gen/datastore.d.ts +129 -0
- package/gen/datastore.d.ts.map +1 -0
- package/gen/datastore.js +303 -0
- package/gen/datastore.js.map +1 -0
- package/gen/session.d.ts +1 -0
- package/gen/session.d.ts.map +1 -1
- package/gen/session.js +1 -0
- package/gen/session.js.map +1 -1
- package/index.d.ts +6 -4
- package/index.d.ts.map +1 -1
- package/index.js +8 -4
- package/index.js.map +1 -1
- package/manifest/client.d.ts +64 -0
- package/manifest/client.d.ts.map +1 -0
- package/manifest/client.js +109 -0
- package/manifest/client.js.map +1 -0
- package/manifest/index.d.ts +9 -0
- package/manifest/index.d.ts.map +1 -0
- package/manifest/index.js +11 -0
- package/manifest/index.js.map +1 -0
- package/manifest/parse.d.ts +57 -0
- package/manifest/parse.d.ts.map +1 -0
- package/manifest/parse.js +134 -0
- package/manifest/parse.js.map +1 -0
- package/manifest/redaction.d.ts +16 -0
- package/manifest/redaction.d.ts.map +1 -0
- package/manifest/redaction.js +19 -0
- package/manifest/redaction.js.map +1 -0
- package/manifest/registry.d.ts +44 -0
- package/manifest/registry.d.ts.map +1 -0
- package/manifest/registry.js +178 -0
- package/manifest/registry.js.map +1 -0
- package/manifest/serialize.d.ts +24 -0
- package/manifest/serialize.d.ts.map +1 -0
- package/manifest/serialize.js +78 -0
- package/manifest/serialize.js.map +1 -0
- package/package.json +4 -3
- package/session.d.ts +37 -0
- package/session.d.ts.map +1 -1
- package/session.js +43 -0
- package/session.js.map +1 -1
- package/src/__tests__/errors.test.ts +58 -0
- package/src/__tests__/manifest.test.ts +271 -0
- package/src/__tests__/session.test.ts +66 -0
- package/src/billing.ts +160 -0
- package/src/cursor-accounts.ts +207 -0
- package/src/errors.ts +27 -0
- package/src/gen/agent.ts +15 -1
- package/src/gen/agentexecution.ts +2 -0
- package/src/gen/agentinstance.ts +2 -0
- package/src/gen/authorization-config.ts +1 -0
- package/src/gen/client.ts +7 -2
- package/src/gen/datastore.ts +381 -0
- package/src/gen/session.ts +2 -0
- package/src/index.ts +36 -1
- package/src/manifest/client.ts +145 -0
- package/src/manifest/index.ts +25 -0
- package/src/manifest/parse.ts +204 -0
- package/src/manifest/redaction.ts +20 -0
- package/src/manifest/registry.ts +232 -0
- package/src/manifest/serialize.ts +92 -0
- package/src/session.ts +48 -0
- package/src/stigmer.ts +8 -0
- package/stigmer.d.ts +6 -0
- package/stigmer.d.ts.map +1 -1
- package/stigmer.js +8 -0
- package/stigmer.js.map +1 -1
package/src/billing.ts
CHANGED
|
@@ -12,12 +12,21 @@ import {
|
|
|
12
12
|
SetAutoRechargeConfigInputSchema,
|
|
13
13
|
GetBillingUsageReportInputSchema,
|
|
14
14
|
GetCustomerModelPricingInputSchema,
|
|
15
|
+
GetModelPricingGovernanceInputSchema,
|
|
16
|
+
DecideModelPricingOverrideInputSchema,
|
|
17
|
+
UpsertModelPricingBaselineInputSchema,
|
|
18
|
+
RetireModelPricingBaselineInputSchema,
|
|
19
|
+
ListModelPricingBaselinesInputSchema,
|
|
15
20
|
type CreateCreditCheckoutSessionResponse,
|
|
16
21
|
type CreateBillingPortalSessionResponse,
|
|
17
22
|
type CreditLedgerResponse,
|
|
18
23
|
type BillingUsageReportResponse,
|
|
19
24
|
type CustomerModelPricingResponse,
|
|
25
|
+
type ModelPricingGovernanceResponse,
|
|
26
|
+
type ModelPricingBaselinesResponse,
|
|
20
27
|
} from "@stigmer/protos/ai/stigmer/billing/v1/io_pb";
|
|
28
|
+
import type { ModelPricingOverride } from "@stigmer/protos/ai/stigmer/billing/v1/pricing_override_pb";
|
|
29
|
+
import type { ModelPricingBaseline } from "@stigmer/protos/ai/stigmer/billing/v1/model_pricing_baseline_pb";
|
|
21
30
|
import type { BillingAccount, CreditBalance } from "@stigmer/protos/ai/stigmer/billing/v1/billing_account_pb";
|
|
22
31
|
import type { LedgerEntryType, LedgerView } from "@stigmer/protos/ai/stigmer/billing/v1/enum_pb";
|
|
23
32
|
import { PageInfoSchema } from "@stigmer/protos/ai/stigmer/commons/rpc/pagination_pb";
|
|
@@ -74,6 +83,49 @@ export interface GetCustomerModelPricingParams {
|
|
|
74
83
|
readonly orgId?: string;
|
|
75
84
|
}
|
|
76
85
|
|
|
86
|
+
/** Parameters for creating or revising a model registry baseline entry. */
|
|
87
|
+
export interface UpsertModelPricingBaselineParams {
|
|
88
|
+
/**
|
|
89
|
+
* The baseline entry to create or revise, keyed by
|
|
90
|
+
* (modelId, provider, harness). Lifecycle fields (baselineId, status,
|
|
91
|
+
* decision stamps, pricing effectiveAt) are server-owned and ignored.
|
|
92
|
+
*/
|
|
93
|
+
readonly baseline: ModelPricingBaseline;
|
|
94
|
+
/** Optional operator note recorded on the revision for the audit trail. */
|
|
95
|
+
readonly revisionNote?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Parameters for retiring a model from the registry catalog. */
|
|
99
|
+
export interface RetireModelPricingBaselineParams {
|
|
100
|
+
readonly modelId: string;
|
|
101
|
+
readonly provider: string;
|
|
102
|
+
readonly harness: string;
|
|
103
|
+
/** Optional operator note recorded on the retirement. */
|
|
104
|
+
readonly revisionNote?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Parameters for listing the model registry baseline catalog. */
|
|
108
|
+
export interface ListModelPricingBaselinesParams {
|
|
109
|
+
/**
|
|
110
|
+
* When `true`, includes SUPERSEDED and RETIRED revisions (the full
|
|
111
|
+
* audit history). Default: ACTIVE documents only.
|
|
112
|
+
*/
|
|
113
|
+
readonly includeHistory?: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Parameters for deciding a pending pricing override. */
|
|
117
|
+
export interface DecideModelPricingOverrideParams {
|
|
118
|
+
/** The PENDING_SIGNOFF override to decide. */
|
|
119
|
+
readonly overrideId: string;
|
|
120
|
+
/**
|
|
121
|
+
* `true` approves (the override becomes ACTIVE and supersedes any
|
|
122
|
+
* current ACTIVE override on the same pricing key); `false` rejects.
|
|
123
|
+
*/
|
|
124
|
+
readonly approve: boolean;
|
|
125
|
+
/** Optional note recorded on the decision for the audit trail. */
|
|
126
|
+
readonly decisionNote?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
77
129
|
/**
|
|
78
130
|
* Client for the billing bounded context.
|
|
79
131
|
*
|
|
@@ -270,4 +322,112 @@ export class BillingClient {
|
|
|
270
322
|
throw wrapError(e);
|
|
271
323
|
}
|
|
272
324
|
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Retrieve the platform pricing governance view: baseline vs effective
|
|
328
|
+
* rates per model, ACTIVE override provenance, and pending sign-off
|
|
329
|
+
* proposals from the pricing feedback loop.
|
|
330
|
+
*
|
|
331
|
+
* Platform-operator surface (`can_manage_model_pricing` on
|
|
332
|
+
* `platform:stigmer`): rates are raw provider prices, pre-markup.
|
|
333
|
+
*/
|
|
334
|
+
async getModelPricingGovernance(): Promise<ModelPricingGovernanceResponse> {
|
|
335
|
+
try {
|
|
336
|
+
return await this.query.getModelPricingGovernance(
|
|
337
|
+
create(GetModelPricingGovernanceInputSchema, {}),
|
|
338
|
+
);
|
|
339
|
+
} catch (e) {
|
|
340
|
+
throw wrapError(e);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Record a human decision on a PENDING_SIGNOFF pricing override.
|
|
346
|
+
*
|
|
347
|
+
* Approving makes the override ACTIVE (superseding any current ACTIVE
|
|
348
|
+
* override on the same pricing key) and recomposes the effective
|
|
349
|
+
* registry; rejecting archives it for audit. Returns the decided
|
|
350
|
+
* override with the decision stamped.
|
|
351
|
+
*/
|
|
352
|
+
async decideModelPricingOverride(
|
|
353
|
+
params: DecideModelPricingOverrideParams,
|
|
354
|
+
): Promise<ModelPricingOverride> {
|
|
355
|
+
try {
|
|
356
|
+
return await this.command.decideModelPricingOverride(
|
|
357
|
+
create(DecideModelPricingOverrideInputSchema, {
|
|
358
|
+
overrideId: params.overrideId,
|
|
359
|
+
approve: params.approve,
|
|
360
|
+
decisionNote: params.decisionNote ?? "",
|
|
361
|
+
}),
|
|
362
|
+
);
|
|
363
|
+
} catch (e) {
|
|
364
|
+
throw wrapError(e);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Retrieve the model registry baseline catalog: ACTIVE entries by
|
|
370
|
+
* default, or the full append-only revision history with
|
|
371
|
+
* `includeHistory`.
|
|
372
|
+
*
|
|
373
|
+
* Platform-operator surface (`can_manage_model_pricing` on
|
|
374
|
+
* `platform:stigmer`): rates are raw provider prices, pre-markup.
|
|
375
|
+
*/
|
|
376
|
+
async listModelPricingBaselines(
|
|
377
|
+
params?: ListModelPricingBaselinesParams,
|
|
378
|
+
): Promise<ModelPricingBaselinesResponse> {
|
|
379
|
+
try {
|
|
380
|
+
return await this.query.listModelPricingBaselines(
|
|
381
|
+
create(ListModelPricingBaselinesInputSchema, {
|
|
382
|
+
includeHistory: params?.includeHistory ?? false,
|
|
383
|
+
}),
|
|
384
|
+
);
|
|
385
|
+
} catch (e) {
|
|
386
|
+
throw wrapError(e);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Create or revise one model registry baseline entry (catalog + list
|
|
392
|
+
* prices). Append-only: an existing ACTIVE entry for the same
|
|
393
|
+
* (modelId, provider, harness) key is superseded, never mutated, and
|
|
394
|
+
* the effective registry recomposes immediately. Returns the new
|
|
395
|
+
* revision with server-stamped lifecycle fields.
|
|
396
|
+
*/
|
|
397
|
+
async upsertModelPricingBaseline(
|
|
398
|
+
params: UpsertModelPricingBaselineParams,
|
|
399
|
+
): Promise<ModelPricingBaseline> {
|
|
400
|
+
try {
|
|
401
|
+
return await this.command.upsertModelPricingBaseline(
|
|
402
|
+
create(UpsertModelPricingBaselineInputSchema, {
|
|
403
|
+
baseline: params.baseline,
|
|
404
|
+
revisionNote: params.revisionNote ?? "",
|
|
405
|
+
}),
|
|
406
|
+
);
|
|
407
|
+
} catch (e) {
|
|
408
|
+
throw wrapError(e);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Retire one model from the registry catalog. The model disappears
|
|
414
|
+
* from every price surface on the next composition pass; the document
|
|
415
|
+
* is kept for audit and the key can be revived by a subsequent upsert.
|
|
416
|
+
*/
|
|
417
|
+
async retireModelPricingBaseline(
|
|
418
|
+
params: RetireModelPricingBaselineParams,
|
|
419
|
+
): Promise<ModelPricingBaseline> {
|
|
420
|
+
try {
|
|
421
|
+
return await this.command.retireModelPricingBaseline(
|
|
422
|
+
create(RetireModelPricingBaselineInputSchema, {
|
|
423
|
+
modelId: params.modelId,
|
|
424
|
+
provider: params.provider,
|
|
425
|
+
harness: params.harness,
|
|
426
|
+
revisionNote: params.revisionNote ?? "",
|
|
427
|
+
}),
|
|
428
|
+
);
|
|
429
|
+
} catch (e) {
|
|
430
|
+
throw wrapError(e);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
273
433
|
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
2
|
+
import { create } from "@bufbuild/protobuf";
|
|
3
|
+
import { CursorAccountCommandController } from "@stigmer/protos/ai/stigmer/platform/cursoraccount/v1/command_pb";
|
|
4
|
+
import { CursorAccountQueryController } from "@stigmer/protos/ai/stigmer/platform/cursoraccount/v1/query_pb";
|
|
5
|
+
import {
|
|
6
|
+
UpsertCursorAccountInputSchema,
|
|
7
|
+
DeleteCursorAccountInputSchema,
|
|
8
|
+
AddCursorMemberKeyInputSchema,
|
|
9
|
+
RemoveCursorMemberKeyInputSchema,
|
|
10
|
+
SetCursorMemberKeyEnabledInputSchema,
|
|
11
|
+
SyncCursorAccountInputSchema,
|
|
12
|
+
ListCursorAccountsInputSchema,
|
|
13
|
+
GetCursorAccountViewInputSchema,
|
|
14
|
+
type CursorAccountsResponse,
|
|
15
|
+
type CursorAccountView,
|
|
16
|
+
} from "@stigmer/protos/ai/stigmer/platform/cursoraccount/v1/io_pb";
|
|
17
|
+
import type { CursorAccount } from "@stigmer/protos/ai/stigmer/platform/cursoraccount/v1/cursor_account_pb";
|
|
18
|
+
import { wrapError } from "./gen/errors.js";
|
|
19
|
+
|
|
20
|
+
/** Parameters for creating or updating a Cursor account. */
|
|
21
|
+
export interface UpsertCursorAccountParams {
|
|
22
|
+
/**
|
|
23
|
+
* The account to create (empty `accountId`) or update. The admin key is
|
|
24
|
+
* plaintext to set/rotate or `"***REDACTED***"` to keep the stored
|
|
25
|
+
* value; member keys on this message are ignored — use
|
|
26
|
+
* {@link CursorAccountsClient.addMemberKey} and friends.
|
|
27
|
+
*/
|
|
28
|
+
readonly account: CursorAccount;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Parameters for deleting a Cursor account. */
|
|
32
|
+
export interface DeleteCursorAccountParams {
|
|
33
|
+
readonly accountId: string;
|
|
34
|
+
/**
|
|
35
|
+
* Deletion is refused while live sessions are pinned to the account's
|
|
36
|
+
* keys. `force: true` overrides — their Cursor agent handles will be
|
|
37
|
+
* orphaned at disposal.
|
|
38
|
+
*/
|
|
39
|
+
readonly force?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Parameters for adding one member key. */
|
|
43
|
+
export interface AddCursorMemberKeyParams {
|
|
44
|
+
readonly accountId: string;
|
|
45
|
+
/**
|
|
46
|
+
* Plaintext user-scoped Cursor API key. Validated live against Cursor's
|
|
47
|
+
* `/v1/me` and bound to its owning team member server-side; admin and
|
|
48
|
+
* service-account keys are rejected with Cursor's own explanation.
|
|
49
|
+
*/
|
|
50
|
+
readonly apiKey: string;
|
|
51
|
+
/** Optional operator label (e.g. `"zane — stigmer-prod"`). */
|
|
52
|
+
readonly label?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Parameters for removing one member key. */
|
|
56
|
+
export interface RemoveCursorMemberKeyParams {
|
|
57
|
+
readonly accountId: string;
|
|
58
|
+
readonly keyId: string;
|
|
59
|
+
/**
|
|
60
|
+
* Removal is refused while live sessions are pinned to this key.
|
|
61
|
+
* `force: true` overrides — prefer disabling instead (always safe).
|
|
62
|
+
*/
|
|
63
|
+
readonly force?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Parameters for enabling/disabling one member key. */
|
|
67
|
+
export interface SetCursorMemberKeyEnabledParams {
|
|
68
|
+
readonly accountId: string;
|
|
69
|
+
readonly keyId: string;
|
|
70
|
+
/**
|
|
71
|
+
* `false` blocks NEW sessions immediately; sessions already pinned to
|
|
72
|
+
* the key keep working (conversation continuity + disposal need it).
|
|
73
|
+
*/
|
|
74
|
+
readonly enabled: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Client for managed Cursor accounts (platform operators only).
|
|
79
|
+
*
|
|
80
|
+
* A Cursor account is one managed Cursor team: its Admin API key (roster
|
|
81
|
+
* and spend, never executions), its member execution keys, and its org
|
|
82
|
+
* assignments. Every method requires `can_manage_cursor_accounts` on
|
|
83
|
+
* `platform:stigmer`; key material is always redacted in responses.
|
|
84
|
+
*/
|
|
85
|
+
export class CursorAccountsClient {
|
|
86
|
+
private readonly command: Client<typeof CursorAccountCommandController>;
|
|
87
|
+
private readonly query: Client<typeof CursorAccountQueryController>;
|
|
88
|
+
|
|
89
|
+
constructor(transport: Transport) {
|
|
90
|
+
this.command = createClient(CursorAccountCommandController, transport);
|
|
91
|
+
this.query = createClient(CursorAccountQueryController, transport);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** List all Cursor accounts with routing/sync summaries. */
|
|
95
|
+
async listAccounts(): Promise<CursorAccountsResponse> {
|
|
96
|
+
try {
|
|
97
|
+
return await this.query.listCursorAccounts(
|
|
98
|
+
create(ListCursorAccountsInputSchema, {}),
|
|
99
|
+
);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
throw wrapError(e);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Retrieve one account's detail view: the redacted account, the latest
|
|
107
|
+
* roster/spend snapshot, and the computed key-coverage join.
|
|
108
|
+
*/
|
|
109
|
+
async getAccountView(accountId: string): Promise<CursorAccountView> {
|
|
110
|
+
try {
|
|
111
|
+
return await this.query.getCursorAccountView(
|
|
112
|
+
create(GetCursorAccountViewInputSchema, { accountId }),
|
|
113
|
+
);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
throw wrapError(e);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Create or update a Cursor account. The admin key is validated live
|
|
121
|
+
* against Cursor's `/teams/members` before persistence.
|
|
122
|
+
*/
|
|
123
|
+
async upsertAccount(params: UpsertCursorAccountParams): Promise<CursorAccount> {
|
|
124
|
+
try {
|
|
125
|
+
return await this.command.upsertCursorAccount(
|
|
126
|
+
create(UpsertCursorAccountInputSchema, { account: params.account }),
|
|
127
|
+
);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
throw wrapError(e);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Delete a Cursor account (guarded against live session pins). */
|
|
134
|
+
async deleteAccount(params: DeleteCursorAccountParams): Promise<CursorAccount> {
|
|
135
|
+
try {
|
|
136
|
+
return await this.command.deleteCursorAccount(
|
|
137
|
+
create(DeleteCursorAccountInputSchema, {
|
|
138
|
+
accountId: params.accountId,
|
|
139
|
+
force: params.force ?? false,
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
} catch (e) {
|
|
143
|
+
throw wrapError(e);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Add one execution-capable member key (identity bound via `/v1/me`). */
|
|
148
|
+
async addMemberKey(params: AddCursorMemberKeyParams): Promise<CursorAccount> {
|
|
149
|
+
try {
|
|
150
|
+
return await this.command.addCursorMemberKey(
|
|
151
|
+
create(AddCursorMemberKeyInputSchema, {
|
|
152
|
+
accountId: params.accountId,
|
|
153
|
+
apiKey: params.apiKey,
|
|
154
|
+
label: params.label ?? "",
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
throw wrapError(e);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Remove one member key (guarded against live session pins). */
|
|
163
|
+
async removeMemberKey(params: RemoveCursorMemberKeyParams): Promise<CursorAccount> {
|
|
164
|
+
try {
|
|
165
|
+
return await this.command.removeCursorMemberKey(
|
|
166
|
+
create(RemoveCursorMemberKeyInputSchema, {
|
|
167
|
+
accountId: params.accountId,
|
|
168
|
+
keyId: params.keyId,
|
|
169
|
+
force: params.force ?? false,
|
|
170
|
+
}),
|
|
171
|
+
);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
throw wrapError(e);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Enable or disable one member key for new-session selection. */
|
|
178
|
+
async setMemberKeyEnabled(
|
|
179
|
+
params: SetCursorMemberKeyEnabledParams,
|
|
180
|
+
): Promise<CursorAccount> {
|
|
181
|
+
try {
|
|
182
|
+
return await this.command.setCursorMemberKeyEnabled(
|
|
183
|
+
create(SetCursorMemberKeyEnabledInputSchema, {
|
|
184
|
+
accountId: params.accountId,
|
|
185
|
+
keyId: params.keyId,
|
|
186
|
+
enabled: params.enabled,
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
throw wrapError(e);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Run an on-demand roster + spend sync and return the refreshed view.
|
|
196
|
+
* Rate-limited upstream (Cursor Admin API) — debounce in UIs.
|
|
197
|
+
*/
|
|
198
|
+
async syncAccount(accountId: string): Promise<CursorAccountView> {
|
|
199
|
+
try {
|
|
200
|
+
return await this.command.syncCursorAccount(
|
|
201
|
+
create(SyncCursorAccountInputSchema, { accountId }),
|
|
202
|
+
);
|
|
203
|
+
} catch (e) {
|
|
204
|
+
throw wrapError(e);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -303,6 +303,33 @@ export function getErrorReason(error: unknown): ErrorReason | null {
|
|
|
303
303
|
return null;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
/**
|
|
307
|
+
* The `google.rpc.ErrorInfo` domain attached by datastore record-RPC
|
|
308
|
+
* errors in both editions (a cross-edition contract; see the OSS
|
|
309
|
+
* `dserrors` package and its Java mirror).
|
|
310
|
+
*/
|
|
311
|
+
const RECORDS_ERROR_DOMAIN = "datastore.stigmer.ai";
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Extract the violated constraint's declared name from a datastore
|
|
315
|
+
* record-RPC error, or `null` when the error carries none.
|
|
316
|
+
*
|
|
317
|
+
* Record writes rejected by a declared constraint (`ALREADY_EXISTS` for
|
|
318
|
+
* uniques, `FAILED_PRECONDITION` for check/exists/not_exists) attach a
|
|
319
|
+
* `google.rpc.ErrorInfo` with reason `CONSTRAINT_VIOLATION` and the
|
|
320
|
+
* constraint's name in `metadata["constraint"]` — the same companion
|
|
321
|
+
* the MCP bridge's record tools surface to agents. Consumers map the
|
|
322
|
+
* name through the datastore spec to place the (verbatim) message next
|
|
323
|
+
* to the fields the constraint covers; `null` falls back to a
|
|
324
|
+
* form-level rendering of {@link getUserMessage}.
|
|
325
|
+
*/
|
|
326
|
+
export function getRecordConstraint(error: unknown): string | null {
|
|
327
|
+
const reason = getErrorReason(error);
|
|
328
|
+
if (!reason || reason.domain !== RECORDS_ERROR_DOMAIN) return null;
|
|
329
|
+
const constraint = reason.metadata["constraint"];
|
|
330
|
+
return constraint !== undefined && constraint !== "" ? constraint : null;
|
|
331
|
+
}
|
|
332
|
+
|
|
306
333
|
/**
|
|
307
334
|
* Metadata about the RPC call that produced an error. Attached by the
|
|
308
335
|
* SDK's metadata interceptor and readable via {@link getRpcMetadata}.
|
package/src/gen/agent.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { AgentSchema, type Agent } from "@stigmer/protos/ai/stigmer/agentic/agen
|
|
|
9
9
|
import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
|
|
10
10
|
import { AgentIdSchema, GetDefaultAgentRequestSchema, type GetDefaultAgentRequest } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/io_pb";
|
|
11
11
|
import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
|
|
12
|
-
import { AgentSpecSchema, ToolApprovalOverrideSchema, McpServerUsageSchema, McpAccessSchema, SubAgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
|
|
12
|
+
import { AgentSpecSchema, ToolApprovalOverrideSchema, McpServerUsageSchema, McpAccessSchema, SubAgentSchema, DatastoreUsageSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
|
|
13
13
|
import { EnvVarDeclarationSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
14
14
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
15
15
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
@@ -112,6 +112,7 @@ export interface AgentInput {
|
|
|
112
112
|
skillRefs?: ResourceRef[];
|
|
113
113
|
subAgents?: SubAgentInput[];
|
|
114
114
|
env?: Record<string, EnvVarDeclarationInput>;
|
|
115
|
+
datastoreUsages?: DatastoreUsageInput[];
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
/** SDK input type for McpServerUsage. */
|
|
@@ -151,6 +152,11 @@ export interface EnvVarDeclarationInput {
|
|
|
151
152
|
optional?: boolean;
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
/** SDK input type for DatastoreUsage. */
|
|
156
|
+
export interface DatastoreUsageInput {
|
|
157
|
+
datastoreRef: ResourceRef;
|
|
158
|
+
}
|
|
159
|
+
|
|
154
160
|
function buildToolApprovalOverrideProto(input: ToolApprovalOverrideInput) {
|
|
155
161
|
return Object.assign(create(ToolApprovalOverrideSchema), stripUndefined({
|
|
156
162
|
toolName: input.toolName,
|
|
@@ -193,6 +199,12 @@ function buildEnvVarDeclarationProto(input: EnvVarDeclarationInput) {
|
|
|
193
199
|
}));
|
|
194
200
|
}
|
|
195
201
|
|
|
202
|
+
function buildDatastoreUsageProto(input: DatastoreUsageInput) {
|
|
203
|
+
const msg = create(DatastoreUsageSchema);
|
|
204
|
+
if (input.datastoreRef?.slug || input.datastoreRef?.org) msg.datastoreRef = create(ApiResourceReferenceSchema, { ...input.datastoreRef, kind: 49 });
|
|
205
|
+
return msg;
|
|
206
|
+
}
|
|
207
|
+
|
|
196
208
|
export function buildAgentProto(input: AgentInput): Agent {
|
|
197
209
|
const mcpServerUsages = input.mcpServerUsages?.map(buildMcpServerUsageProto);
|
|
198
210
|
const skillRefs = input.skillRefs?.map(r => create(ApiResourceReferenceSchema, { ...r, kind: 43 }));
|
|
@@ -201,6 +213,7 @@ export function buildAgentProto(input: AgentInput): Agent {
|
|
|
201
213
|
if (input.env) {
|
|
202
214
|
env = Object.fromEntries(Object.entries(input.env).map(([k, v]) => [k, buildEnvVarDeclarationProto(v)]));
|
|
203
215
|
}
|
|
216
|
+
const datastoreUsages = input.datastoreUsages?.map(buildDatastoreUsageProto);
|
|
204
217
|
return Object.assign(create(AgentSchema), {
|
|
205
218
|
apiVersion: "agentic.stigmer.ai/v1",
|
|
206
219
|
kind: "Agent",
|
|
@@ -219,6 +232,7 @@ export function buildAgentProto(input: AgentInput): Agent {
|
|
|
219
232
|
skillRefs,
|
|
220
233
|
subAgents,
|
|
221
234
|
env,
|
|
235
|
+
datastoreUsages,
|
|
222
236
|
})),
|
|
223
237
|
}) as Agent;
|
|
224
238
|
}
|
|
@@ -198,6 +198,7 @@ export interface SessionSpecInput {
|
|
|
198
198
|
agentInstanceId?: string;
|
|
199
199
|
subject?: string;
|
|
200
200
|
harnessStateId?: string;
|
|
201
|
+
harnessStateIdHistory?: string[];
|
|
201
202
|
metadata?: Record<string, string>;
|
|
202
203
|
workspaceEntries?: WorkspaceEntryInput[];
|
|
203
204
|
mcpServerUsages?: McpServerUsageInput[];
|
|
@@ -331,6 +332,7 @@ function buildSessionSpecProto(input: SessionSpecInput) {
|
|
|
331
332
|
if (input.agentInstanceId !== undefined) msg.agentInstanceId = input.agentInstanceId;
|
|
332
333
|
if (input.subject !== undefined) msg.subject = input.subject;
|
|
333
334
|
if (input.harnessStateId !== undefined) msg.harnessStateId = input.harnessStateId;
|
|
335
|
+
if (input.harnessStateIdHistory) msg.harnessStateIdHistory = input.harnessStateIdHistory;
|
|
334
336
|
if (input.metadata) Object.assign(msg.metadata, input.metadata);
|
|
335
337
|
if (input.workspaceEntries) msg.workspaceEntries = input.workspaceEntries.map(buildWorkspaceEntryProto);
|
|
336
338
|
if (input.mcpServerUsages) msg.mcpServerUsages = input.mcpServerUsages.map(buildMcpServerUsageProto);
|
package/src/gen/agentinstance.ts
CHANGED
|
@@ -90,6 +90,7 @@ export interface AgentInstanceInput {
|
|
|
90
90
|
agentId?: string;
|
|
91
91
|
description?: string;
|
|
92
92
|
environmentRefs?: ResourceRef[];
|
|
93
|
+
datastorePartition?: string;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
export function buildAgentInstanceProto(input: AgentInstanceInput): AgentInstance {
|
|
@@ -108,6 +109,7 @@ export function buildAgentInstanceProto(input: AgentInstanceInput): AgentInstanc
|
|
|
108
109
|
agentId: input.agentId,
|
|
109
110
|
description: input.description,
|
|
110
111
|
environmentRefs,
|
|
112
|
+
datastorePartition: input.datastorePartition,
|
|
111
113
|
})),
|
|
112
114
|
}) as AgentInstance;
|
|
113
115
|
}
|
|
@@ -26,6 +26,7 @@ export const GRANTABLE_ROLES: ReadonlyMap<ApiResourceKind, readonly IamRole[]> =
|
|
|
26
26
|
[ApiResourceKind.agent_share, [IamRole.owner, IamRole.viewer]],
|
|
27
27
|
[ApiResourceKind.agent_channel, [IamRole.owner, IamRole.viewer]],
|
|
28
28
|
[ApiResourceKind.channel_app, [IamRole.owner, IamRole.viewer]],
|
|
29
|
+
[ApiResourceKind.datastore, [IamRole.owner, IamRole.viewer]],
|
|
29
30
|
[ApiResourceKind.workflow, [IamRole.owner, IamRole.viewer]],
|
|
30
31
|
[ApiResourceKind.workflow_instance, [IamRole.owner, IamRole.viewer]],
|
|
31
32
|
[ApiResourceKind.workflow_execution, [IamRole.owner, IamRole.viewer]],
|
package/src/gen/client.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { AgentShareClient } from "./agentshare.js";
|
|
|
9
9
|
import { ApiKeyClient } from "./apikey.js";
|
|
10
10
|
import { ArtifactClient } from "./artifact.js";
|
|
11
11
|
import { ChannelAppClient } from "./channelapp.js";
|
|
12
|
+
import { DatastoreClient } from "./datastore.js";
|
|
12
13
|
import { EnvironmentClient } from "./environment.js";
|
|
13
14
|
import { ExecutionContextClient } from "./executioncontext.js";
|
|
14
15
|
import { IamPolicyClient } from "./iampolicy.js";
|
|
@@ -36,6 +37,7 @@ export class GeneratedClient {
|
|
|
36
37
|
readonly apiKey: ApiKeyClient;
|
|
37
38
|
readonly artifact: ArtifactClient;
|
|
38
39
|
readonly channelapp: ChannelAppClient;
|
|
40
|
+
readonly datastore: DatastoreClient;
|
|
39
41
|
readonly environment: EnvironmentClient;
|
|
40
42
|
readonly executionContext: ExecutionContextClient;
|
|
41
43
|
readonly iamPolicy: IamPolicyClient;
|
|
@@ -62,6 +64,7 @@ export class GeneratedClient {
|
|
|
62
64
|
this.apiKey = new ApiKeyClient(transport);
|
|
63
65
|
this.artifact = new ArtifactClient(transport);
|
|
64
66
|
this.channelapp = new ChannelAppClient(transport);
|
|
67
|
+
this.datastore = new DatastoreClient(transport);
|
|
65
68
|
this.environment = new EnvironmentClient(transport);
|
|
66
69
|
this.executionContext = new ExecutionContextClient(transport);
|
|
67
70
|
this.iamPolicy = new IamPolicyClient(transport);
|
|
@@ -83,7 +86,7 @@ export class GeneratedClient {
|
|
|
83
86
|
|
|
84
87
|
// Re-export all resource client types and input types.
|
|
85
88
|
export { AgentClient } from "./agent.js";
|
|
86
|
-
export { type AgentInput, type McpServerUsageInput, type ToolApprovalOverrideInput, type SubAgentInput, type McpAccessInput, type EnvVarDeclarationInput } from "./agent.js";
|
|
89
|
+
export { type AgentInput, type McpServerUsageInput, type ToolApprovalOverrideInput, type SubAgentInput, type McpAccessInput, type EnvVarDeclarationInput, type DatastoreUsageInput } from "./agent.js";
|
|
87
90
|
export { AgentChannelClient } from "./agentchannel.js";
|
|
88
91
|
export { type AgentChannelInput, type SlackChannelConfigInput, type WhatsAppChannelConfigInput } from "./agentchannel.js";
|
|
89
92
|
export { AgentExecutionClient } from "./agentexecution.js";
|
|
@@ -98,12 +101,14 @@ export { ArtifactClient } from "./artifact.js";
|
|
|
98
101
|
export { type ArtifactInput, type ArtifactSourceInput, type RetentionPolicyInput } from "./artifact.js";
|
|
99
102
|
export { ChannelAppClient } from "./channelapp.js";
|
|
100
103
|
export { type ChannelAppInput, type SlackChannelAppConfigInput, type WhatsAppChannelAppConfigInput } from "./channelapp.js";
|
|
104
|
+
export { DatastoreClient } from "./datastore.js";
|
|
105
|
+
export { type DatastoreInput, type DatastoreAuthorizationInput, type DatastoreRoleInput, type DatastoreRoleBindingInput, type DatastoreSubjectInput, type ChannelSenderSubjectInput, type ApiResourceRefInput, type CollectionDeclarationInput, type FieldDeclarationInput, type UniqueConstraintInput, type UniqueWhereInput, type CheckConstraintInput, type ExistsConstraintInput, type DatastoreGrantInput } from "./datastore.js";
|
|
101
106
|
export { EnvironmentClient } from "./environment.js";
|
|
102
107
|
export { type EnvironmentInput } from "./environment.js";
|
|
103
108
|
export { ExecutionContextClient } from "./executioncontext.js";
|
|
104
109
|
export { type ExecutionContextInput } from "./executioncontext.js";
|
|
105
110
|
export { IamPolicyClient } from "./iampolicy.js";
|
|
106
|
-
export { type IamPolicyInput
|
|
111
|
+
export { type IamPolicyInput } from "./iampolicy.js";
|
|
107
112
|
export { IdentityAccountClient } from "./identityaccount.js";
|
|
108
113
|
export { type IdentityAccountInput } from "./identityaccount.js";
|
|
109
114
|
export { IdentityProviderClient } from "./identityprovider.js";
|