@stigmer/sdk 3.12.3 → 3.12.5

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 (107) hide show
  1. package/__tests__/billing.test.js +36 -0
  2. package/__tests__/billing.test.js.map +1 -1
  3. package/__tests__/mcpserver-connect.test.d.ts +2 -0
  4. package/__tests__/mcpserver-connect.test.d.ts.map +1 -0
  5. package/__tests__/mcpserver-connect.test.js +146 -0
  6. package/__tests__/mcpserver-connect.test.js.map +1 -0
  7. package/__tests__/skill.test.d.ts +2 -0
  8. package/__tests__/skill.test.d.ts.map +1 -0
  9. package/__tests__/skill.test.js +117 -0
  10. package/__tests__/skill.test.js.map +1 -0
  11. package/__tests__/update-input.test.d.ts +2 -0
  12. package/__tests__/update-input.test.d.ts.map +1 -0
  13. package/__tests__/update-input.test.js +169 -0
  14. package/__tests__/update-input.test.js.map +1 -0
  15. package/billing.d.ts +27 -0
  16. package/billing.d.ts.map +1 -1
  17. package/billing.js +26 -1
  18. package/billing.js.map +1 -1
  19. package/errors.d.ts +1 -1
  20. package/errors.d.ts.map +1 -1
  21. package/errors.js +1 -1
  22. package/errors.js.map +1 -1
  23. package/execution/__tests__/tool-view.fixtures.test.js +23 -4
  24. package/execution/__tests__/tool-view.fixtures.test.js.map +1 -1
  25. package/execution/tool-view.d.ts +32 -0
  26. package/execution/tool-view.d.ts.map +1 -1
  27. package/execution/tool-view.js +45 -0
  28. package/execution/tool-view.js.map +1 -1
  29. package/gen/agentexecution.d.ts +6 -0
  30. package/gen/agentexecution.d.ts.map +1 -1
  31. package/gen/agentexecution.js +9 -1
  32. package/gen/agentexecution.js.map +1 -1
  33. package/gen/client.d.ts +4 -4
  34. package/gen/client.d.ts.map +1 -1
  35. package/gen/client.js +1 -1
  36. package/gen/client.js.map +1 -1
  37. package/gen/errors.d.ts +7 -0
  38. package/gen/errors.d.ts.map +1 -1
  39. package/gen/errors.js +9 -0
  40. package/gen/errors.js.map +1 -1
  41. package/gen/identityaccount.d.ts +8 -0
  42. package/gen/identityaccount.d.ts.map +1 -1
  43. package/gen/identityaccount.js +11 -1
  44. package/gen/identityaccount.js.map +1 -1
  45. package/gen/mcpserver.d.ts +1 -0
  46. package/gen/mcpserver.d.ts.map +1 -1
  47. package/gen/mcpserver.js +8 -0
  48. package/gen/mcpserver.js.map +1 -1
  49. package/gen/oauthapp.d.ts +2 -1
  50. package/gen/oauthapp.d.ts.map +1 -1
  51. package/gen/oauthapp.js +1 -0
  52. package/gen/oauthapp.js.map +1 -1
  53. package/gen/organization.d.ts +5 -0
  54. package/gen/organization.d.ts.map +1 -1
  55. package/gen/organization.js +8 -1
  56. package/gen/organization.js.map +1 -1
  57. package/gen/platformclient.d.ts +1 -0
  58. package/gen/platformclient.d.ts.map +1 -1
  59. package/gen/platformclient.js +2 -0
  60. package/gen/platformclient.js.map +1 -1
  61. package/index.d.ts +6 -2
  62. package/index.d.ts.map +1 -1
  63. package/index.js +8 -2
  64. package/index.js.map +1 -1
  65. package/mcpserver-connect.d.ts +79 -0
  66. package/mcpserver-connect.d.ts.map +1 -0
  67. package/mcpserver-connect.js +114 -0
  68. package/mcpserver-connect.js.map +1 -0
  69. package/package.json +2 -2
  70. package/provider-standing.d.ts +19 -0
  71. package/provider-standing.d.ts.map +1 -0
  72. package/provider-standing.js +31 -0
  73. package/provider-standing.js.map +1 -0
  74. package/skill.d.ts +51 -0
  75. package/skill.d.ts.map +1 -0
  76. package/skill.js +102 -0
  77. package/skill.js.map +1 -0
  78. package/src/__tests__/billing.test.ts +44 -0
  79. package/src/__tests__/mcpserver-connect.test.ts +181 -0
  80. package/src/__tests__/skill.test.ts +150 -0
  81. package/src/__tests__/update-input.test.ts +219 -0
  82. package/src/billing.ts +44 -0
  83. package/src/errors.ts +1 -0
  84. package/src/execution/__tests__/tool-view.fixtures.test.ts +41 -4
  85. package/src/execution/tool-view.ts +52 -0
  86. package/src/gen/agentexecution.ts +17 -1
  87. package/src/gen/client.ts +4 -4
  88. package/src/gen/errors.ts +10 -0
  89. package/src/gen/identityaccount.ts +21 -1
  90. package/src/gen/mcpserver.ts +6 -0
  91. package/src/gen/oauthapp.ts +3 -1
  92. package/src/gen/organization.ts +15 -1
  93. package/src/gen/platformclient.ts +3 -0
  94. package/src/index.ts +22 -0
  95. package/src/mcpserver-connect.ts +159 -0
  96. package/src/provider-standing.ts +37 -0
  97. package/src/skill.ts +125 -0
  98. package/src/stigmer.ts +12 -0
  99. package/src/update-input.ts +168 -0
  100. package/stigmer.d.ts +10 -0
  101. package/stigmer.d.ts.map +1 -1
  102. package/stigmer.js +12 -0
  103. package/stigmer.js.map +1 -1
  104. package/update-input.d.ts +24 -0
  105. package/update-input.d.ts.map +1 -0
  106. package/update-input.js +126 -0
  107. package/update-input.js.map +1 -0
@@ -228,6 +228,58 @@ export function resolveToolKindByName(name: string, mcpServerSlug?: string): Too
228
228
  return ToolKind.UNSPECIFIED;
229
229
  }
230
230
 
231
+ // ---------------------------------------------------------------------------
232
+ // Intent: extractShellIntent
233
+ // ---------------------------------------------------------------------------
234
+
235
+ /**
236
+ * The tool-call argument that carries a model-authored intent phrase for
237
+ * SHELL tools (stigmer#276) — a short human description of what the command
238
+ * does and why, rendered as the row title with the command as secondary text.
239
+ *
240
+ * Two writers populate it, converged on one wire key by design: the native
241
+ * harness's tool-intent middleware (`backend/services/runner/src/middleware/
242
+ * tool-intent.ts`, `INTENT_ARG`) extends the shell tool's bind-time schema
243
+ * with it, and the Cursor harness's built-in Shell tool carries it natively.
244
+ * The shared, machine-checked contract is
245
+ * `test/fixtures/tool-view/intent-title.json` — keep the writers and this
246
+ * reader in lockstep.
247
+ */
248
+ export const SHELL_INTENT_ARG_FIELD = "description";
249
+
250
+ /**
251
+ * Args-level intent extraction: SHELL-kind-scoped on purpose, because
252
+ * `description` means other things on other tools (a task tool's description
253
+ * is the sub-agent subject, never a row title). Blank and non-string values
254
+ * degrade to null — callers fall back to their category label.
255
+ *
256
+ * The seam for surfaces that hold a pre-resolved kind and raw args instead of
257
+ * a full ToolCall: the CLI's headless snapshot projection and @stigmer/react's
258
+ * approval argsPreview path. Everything else should prefer
259
+ * {@link extractShellIntent}.
260
+ */
261
+ export function shellIntentFromArgs(
262
+ kind: ToolKind,
263
+ args: Record<string, unknown> | undefined,
264
+ ): string | null {
265
+ if (kind !== ToolKind.SHELL || !args) return null;
266
+ const value = args[SHELL_INTENT_ARG_FIELD];
267
+ if (typeof value !== "string") return null;
268
+ const trimmed = value.trim();
269
+ return trimmed.length > 0 ? trimmed : null;
270
+ }
271
+
272
+ /**
273
+ * Extracts the model-authored intent phrase from a SHELL tool call, or null
274
+ * when absent (legacy executions, models that skipped the optional arg, and
275
+ * every non-shell kind). See {@link SHELL_INTENT_ARG_FIELD}.
276
+ */
277
+ export function extractShellIntent(
278
+ toolCall: Pick<ToolCall, "name" | "mcpServerSlug" | "toolKind" | "args">,
279
+ ): string | null {
280
+ return shellIntentFromArgs(resolveToolKind(toolCall), toolCall.args as Args);
281
+ }
282
+
231
283
  // ---------------------------------------------------------------------------
232
284
  // Result: normalizeToolResult
233
285
  // ---------------------------------------------------------------------------
@@ -11,7 +11,7 @@ import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agen
11
11
  import { InteractionMode, ApprovalMode, ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
12
12
  import { AgentExecutionIdSchema, AgentExecutionUpdateStatusInputSchema, UpdateStatusResponseSchema, SubmitApprovalInputSchema, SubmitFileDecisionInputSchema, CancelAgentExecutionInputSchema, TerminateAgentExecutionInputSchema, RecoverAgentExecutionInputSchema, PauseAgentExecutionInputSchema, ResumeAgentExecutionInputSchema, UploadAttachmentRequestSchema, UploadAttachmentResponseSchema, ListAgentExecutionsRequestSchema, AgentExecutionListSchema, ListAgentExecutionsBySessionRequestSchema, GetArtifactDownloadUrlRequestSchema, GetArtifactDownloadUrlResponseSchema, GetArtifactContentRequestSchema, GetArtifactContentResponseSchema, GetExecutionUsageReportInputSchema, GetExecutionUsageReportOutputSchema, GetSessionUsageReportInputSchema, GetSessionUsageReportOutputSchema, GetAgentUsageReportInputSchema, GetAgentUsageReportOutputSchema, GetOrgUsageReportInputSchema, GetOrgUsageReportOutputSchema, GetAgentExecutionSummaryRequestSchema, AgentExecutionSummarySchema, type AgentExecutionUpdateStatusInput, type UpdateStatusResponse, type SubmitApprovalInput, type SubmitFileDecisionInput, type CancelAgentExecutionInput, type TerminateAgentExecutionInput, type RecoverAgentExecutionInput, type PauseAgentExecutionInput, type ResumeAgentExecutionInput, type UploadAttachmentRequest, type UploadAttachmentResponse, type ListAgentExecutionsRequest, type AgentExecutionList, type ListAgentExecutionsBySessionRequest, type GetArtifactDownloadUrlRequest, type GetArtifactDownloadUrlResponse, type GetArtifactContentRequest, type GetArtifactContentResponse, type GetExecutionUsageReportInput, type GetExecutionUsageReportOutput, type GetSessionUsageReportInput, type GetSessionUsageReportOutput, type GetAgentUsageReportInput, type GetAgentUsageReportOutput, type GetOrgUsageReportInput, type GetOrgUsageReportOutput, type GetAgentExecutionSummaryRequest, type AgentExecutionSummary } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/io_pb";
13
13
  import { AgentExecutionQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/query_pb";
14
- import { AgentExecutionSpecSchema, ContextManagementConfigSchema, ExecutionConfigSchema, AttachmentSchema, ConversationCatchupSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
14
+ import { AgentExecutionSpecSchema, ContextManagementConfigSchema, ExecutionConfigSchema, AttachmentSchema, ConversationCatchupSchema, DeclaredPreferencesSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
15
15
  import { ExecutionValueSchema } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
16
16
  import { Harness, CursorMode, ExecutionTarget, GitWriteBackMode } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
17
17
  import { SessionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/spec_pb";
@@ -192,6 +192,7 @@ export interface AgentExecutionInput {
192
192
  activityTaskQueue?: string;
193
193
  supersedesExecutionId?: string;
194
194
  conversationCatchup?: ConversationCatchupInput;
195
+ declaredPreferences?: DeclaredPreferencesInput;
195
196
  }
196
197
 
197
198
  /** SDK input type for SessionSpec. */
@@ -286,6 +287,12 @@ export interface ConversationCatchupInput {
286
287
  windowEnd?: Date | string;
287
288
  }
288
289
 
290
+ /** SDK input type for DeclaredPreferences. */
291
+ export interface DeclaredPreferencesInput {
292
+ orgContext?: string;
293
+ userContext?: string;
294
+ }
295
+
289
296
  function buildGitRepoSourceProto(input: GitRepoSourceInput) {
290
297
  return Object.assign(create(GitRepoSourceSchema), stripUndefined({
291
298
  url: input.url,
@@ -392,6 +399,13 @@ function buildConversationCatchupProto(input: ConversationCatchupInput) {
392
399
  return msg;
393
400
  }
394
401
 
402
+ function buildDeclaredPreferencesProto(input: DeclaredPreferencesInput) {
403
+ return Object.assign(create(DeclaredPreferencesSchema), stripUndefined({
404
+ orgContext: input.orgContext,
405
+ userContext: input.userContext,
406
+ }));
407
+ }
408
+
395
409
  export function buildAgentExecutionProto(input: AgentExecutionInput): AgentExecution {
396
410
  const sessionSpec = input.sessionSpec ? buildSessionSpecProto(input.sessionSpec) : undefined;
397
411
  const executionConfig = input.executionConfig ? buildExecutionConfigProto(input.executionConfig) : undefined;
@@ -402,6 +416,7 @@ export function buildAgentExecutionProto(input: AgentExecutionInput): AgentExecu
402
416
  }
403
417
  const attachments = input.attachments?.map(buildAttachmentProto);
404
418
  const conversationCatchup = input.conversationCatchup ? buildConversationCatchupProto(input.conversationCatchup) : undefined;
419
+ const declaredPreferences = input.declaredPreferences ? buildDeclaredPreferencesProto(input.declaredPreferences) : undefined;
405
420
  return Object.assign(create(AgentExecutionSchema), {
406
421
  apiVersion: "agentic.stigmer.ai/v1",
407
422
  kind: "AgentExecution",
@@ -427,6 +442,7 @@ export function buildAgentExecutionProto(input: AgentExecutionInput): AgentExecu
427
442
  activityTaskQueue: input.activityTaskQueue,
428
443
  supersedesExecutionId: input.supersedesExecutionId,
429
444
  conversationCatchup,
445
+ declaredPreferences,
430
446
  })),
431
447
  }) as AgentExecution;
432
448
  }
package/src/gen/client.ts CHANGED
@@ -90,7 +90,7 @@ export { type AgentInput, type McpServerUsageInput, type ToolApprovalOverrideInp
90
90
  export { AgentChannelClient } from "./agentchannel.js";
91
91
  export { type AgentChannelInput, type SlackChannelConfigInput, type WhatsAppChannelConfigInput, type RunConfigInput } from "./agentchannel.js";
92
92
  export { AgentExecutionClient } from "./agentexecution.js";
93
- export { type AgentExecutionInput, type SessionSpecInput, type WorkspaceEntryInput, type WorkspaceSourceInput, type GitRepoSourceInput, type LocalPathSourceInput, type ExecutionConfigInput, type ContextManagementConfigInput, type AttachmentInput, type ConversationCatchupInput } from "./agentexecution.js";
93
+ export { type AgentExecutionInput, type SessionSpecInput, type WorkspaceEntryInput, type WorkspaceSourceInput, type GitRepoSourceInput, type LocalPathSourceInput, type ExecutionConfigInput, type ContextManagementConfigInput, type AttachmentInput, type ConversationCatchupInput, type DeclaredPreferencesInput } from "./agentexecution.js";
94
94
  export { AgentInstanceClient } from "./agentinstance.js";
95
95
  export { type AgentInstanceInput } from "./agentinstance.js";
96
96
  export { AgentShareClient } from "./agentshare.js";
@@ -108,7 +108,7 @@ export { type ExecutionContextInput } from "./executioncontext.js";
108
108
  export { IamPolicyClient } from "./iampolicy.js";
109
109
  export { type IamPolicyInput, type ApiResourceRefInput } from "./iampolicy.js";
110
110
  export { IdentityAccountClient } from "./identityaccount.js";
111
- export { type IdentityAccountInput } from "./identityaccount.js";
111
+ export { type IdentityAccountInput, type IdentityAccountPreferencesInput } from "./identityaccount.js";
112
112
  export { IdentityProviderClient } from "./identityprovider.js";
113
113
  export { type IdentityProviderInput } from "./identityprovider.js";
114
114
  export { InvitationClient } from "./invitation.js";
@@ -118,7 +118,7 @@ export { type McpServerInput, type StdioServerConfigInput, type HttpServerConfig
118
118
  export { OAuthAppClient } from "./oauthapp.js";
119
119
  export { type OAuthAppInput } from "./oauthapp.js";
120
120
  export { OrganizationClient } from "./organization.js";
121
- export { type OrganizationInput } from "./organization.js";
121
+ export { type OrganizationInput, type OrganizationPreferencesInput } from "./organization.js";
122
122
  export { PlatformClientClient } from "./platformclient.js";
123
123
  export { type PlatformClientInput } from "./platformclient.js";
124
124
  export { ProjectClient } from "./project.js";
@@ -136,4 +136,4 @@ export { type WorkflowExecutionInput } from "./workflowexecution.js";
136
136
  export { WorkflowInstanceClient } from "./workflowinstance.js";
137
137
  export { type WorkflowInstanceInput } from "./workflowinstance.js";
138
138
  export { type ListParams, type ListResult, type DeleteResourceInput, type ResourceRef, type EnvSpecInput, type EnvVarInput, type Page } from "./types.js";
139
- export { StigmerError, type ErrorCode, isNotFound, isUnauthenticated, isPermissionDenied, isRetryable } from "./errors.js";
139
+ export { StigmerError, type ErrorCode, isNotFound, isUnauthenticated, isPermissionDenied, isRetryable, isUnimplemented } from "./errors.js";
package/src/gen/errors.ts CHANGED
@@ -74,3 +74,13 @@ export function isPermissionDenied(err: unknown): boolean {
74
74
  export function isRetryable(err: unknown): boolean {
75
75
  return err instanceof StigmerError && (err.code === "internal" || err.code === "unavailable");
76
76
  }
77
+
78
+ /**
79
+ * The server does not implement the called RPC — the code clients key
80
+ * capability fallbacks on (e.g. the skill artifact transfer lane's unary
81
+ * fallback, stigmer#675/#701). Checks the raw connect code: Unimplemented
82
+ * deliberately has no ErrorCode mapping, so it surfaces as "unknown".
83
+ */
84
+ export function isUnimplemented(err: unknown): boolean {
85
+ return err instanceof StigmerError && err.connectCode === Code.Unimplemented;
86
+ }
@@ -15,7 +15,7 @@ import { IdentityAccountCommandController } from "@stigmer/protos/ai/stigmer/iam
15
15
  import { IdentityAccountProvisioningMode } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/enum_pb";
16
16
  import { IdentityAccountIdSchema, CreateFederatedAccountInputSchema, UpdateFederatedAccountInputSchema, DeprovisionFederatedAccountInputSchema, IdentityAccountEmailSchema, IdpIdSchema, ExternalSubLookupSchema, type CreateFederatedAccountInput, type UpdateFederatedAccountInput, type DeprovisionFederatedAccountInput, type IdentityAccountEmail, type ExternalSubLookup } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/io_pb";
17
17
  import { IdentityAccountQueryController } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/query_pb";
18
- import { IdentityAccountSpecSchema } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/spec_pb";
18
+ import { IdentityAccountSpecSchema, IdentityAccountPreferencesSchema } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/spec_pb";
19
19
 
20
20
  /** Provides operations on identityaccount resources. */
21
21
  export class IdentityAccountClient {
@@ -121,10 +121,29 @@ export interface IdentityAccountInput {
121
121
  isMachineAccount?: boolean;
122
122
  provisioningMode?: IdentityAccountProvisioningMode;
123
123
  identityProviderRef?: ResourceRef;
124
+ preferences?: IdentityAccountPreferencesInput;
125
+ }
126
+
127
+ /** SDK input type for IdentityAccountPreferences. */
128
+ export interface IdentityAccountPreferencesInput {
129
+ standingContext?: string;
130
+ defaultHarness?: string;
131
+ defaultNativeModel?: string;
132
+ defaultCursorModel?: string;
133
+ }
134
+
135
+ function buildIdentityAccountPreferencesProto(input: IdentityAccountPreferencesInput) {
136
+ return Object.assign(create(IdentityAccountPreferencesSchema), stripUndefined({
137
+ standingContext: input.standingContext,
138
+ defaultHarness: input.defaultHarness,
139
+ defaultNativeModel: input.defaultNativeModel,
140
+ defaultCursorModel: input.defaultCursorModel,
141
+ }));
124
142
  }
125
143
 
126
144
  export function buildIdentityAccountProto(input: IdentityAccountInput): IdentityAccount {
127
145
  const identityProviderRef = (input.identityProviderRef?.slug || input.identityProviderRef?.org) ? create(ApiResourceReferenceSchema, input.identityProviderRef) : undefined;
146
+ const preferences = input.preferences ? buildIdentityAccountPreferencesProto(input.preferences) : undefined;
128
147
  return Object.assign(create(IdentityAccountSchema), {
129
148
  apiVersion: "iam.stigmer.ai/v1",
130
149
  kind: "IdentityAccount",
@@ -144,6 +163,7 @@ export function buildIdentityAccountProto(input: IdentityAccountInput): Identity
144
163
  isMachineAccount: input.isMachineAccount,
145
164
  provisioningMode: input.provisioningMode,
146
165
  identityProviderRef,
166
+ preferences,
147
167
  })),
148
168
  }) as IdentityAccount;
149
169
  }
@@ -71,6 +71,12 @@ export class McpServerClient {
71
71
  } catch (e) { throw wrapError(e); }
72
72
  }
73
73
 
74
+ async startConnect(input: ConnectInput): Promise<McpServer> {
75
+ try {
76
+ return await this.command.startConnect(input);
77
+ } catch (e) { throw wrapError(e); }
78
+ }
79
+
74
80
  async initiateOAuthConnect(input: InitiateOAuthConnectInput): Promise<InitiateOAuthConnectOutput> {
75
81
  try {
76
82
  return await this.command.initiateOAuthConnect(input);
@@ -13,7 +13,7 @@ import { OAuthAppSchema, type OAuthApp } from "@stigmer/protos/ai/stigmer/iam/oa
13
13
  import { OAuthAppCommandController } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/command_pb";
14
14
  import { ListOAuthAppsByOrgInputSchema, OAuthAppsSchema, type ListOAuthAppsByOrgInput, type OAuthApps } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/io_pb";
15
15
  import { OAuthAppQueryController } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/query_pb";
16
- import { OAuthAppSpecSchema, VendorApprovalStatus } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/spec_pb";
16
+ import { OAuthAppSpecSchema, VendorApprovalStatus, TokenEndpointAuthMethod } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/spec_pb";
17
17
 
18
18
  /** Provides operations on oauthapp resources. */
19
19
  export class OAuthAppClient {
@@ -89,6 +89,7 @@ export interface OAuthAppInput {
89
89
  scopeParameterName?: string;
90
90
  vendorApprovalStatus?: VendorApprovalStatus;
91
91
  vendorApprovalDocsUrl?: string;
92
+ tokenEndpointAuthMethod?: TokenEndpointAuthMethod;
92
93
  }
93
94
 
94
95
  export function buildOAuthAppProto(input: OAuthAppInput): OAuthApp {
@@ -113,6 +114,7 @@ export function buildOAuthAppProto(input: OAuthAppInput): OAuthApp {
113
114
  scopeParameterName: input.scopeParameterName,
114
115
  vendorApprovalStatus: input.vendorApprovalStatus,
115
116
  vendorApprovalDocsUrl: input.vendorApprovalDocsUrl,
117
+ tokenEndpointAuthMethod: input.tokenEndpointAuthMethod,
116
118
  })),
117
119
  }) as OAuthApp;
118
120
  }
@@ -14,7 +14,7 @@ import { OrganizationCommandController } from "@stigmer/protos/ai/stigmer/tenanc
14
14
  import { ManagementMode } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/enum_pb";
15
15
  import { OrganizationIdSchema, OrganizationListSchema, OrganizationsSchema, OrganizationExternalLookupSchema, type OrganizationList, type Organizations, type OrganizationExternalLookup } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/io_pb";
16
16
  import { OrganizationQueryController } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/query_pb";
17
- import { OrganizationSpecSchema } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/spec_pb";
17
+ import { OrganizationSpecSchema, OrganizationPreferencesSchema } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/spec_pb";
18
18
 
19
19
  /** Provides operations on organization resources. */
20
20
  export class OrganizationClient {
@@ -88,10 +88,23 @@ export interface OrganizationInput {
88
88
  identityProviderRef?: ResourceRef;
89
89
  externalOrgId?: string;
90
90
  isPersonal?: boolean;
91
+ preferences?: OrganizationPreferencesInput;
92
+ }
93
+
94
+ /** SDK input type for OrganizationPreferences. */
95
+ export interface OrganizationPreferencesInput {
96
+ standingContext?: string;
97
+ }
98
+
99
+ function buildOrganizationPreferencesProto(input: OrganizationPreferencesInput) {
100
+ return Object.assign(create(OrganizationPreferencesSchema), stripUndefined({
101
+ standingContext: input.standingContext,
102
+ }));
91
103
  }
92
104
 
93
105
  export function buildOrganizationProto(input: OrganizationInput): Organization {
94
106
  const identityProviderRef = (input.identityProviderRef?.slug || input.identityProviderRef?.org) ? create(ApiResourceReferenceSchema, input.identityProviderRef) : undefined;
107
+ const preferences = input.preferences ? buildOrganizationPreferencesProto(input.preferences) : undefined;
95
108
  return Object.assign(create(OrganizationSchema), {
96
109
  apiVersion: "tenancy.stigmer.ai/v1",
97
110
  kind: "Organization",
@@ -109,6 +122,7 @@ export function buildOrganizationProto(input: OrganizationInput): Organization {
109
122
  identityProviderRef,
110
123
  externalOrgId: input.externalOrgId,
111
124
  isPersonal: input.isPersonal,
125
+ preferences,
112
126
  })),
113
127
  }) as Organization;
114
128
  }
@@ -104,10 +104,12 @@ export interface PlatformClientInput {
104
104
  autoGrantOnOrg?: boolean;
105
105
  autoGrantRole?: IamRole;
106
106
  allowedOrigins?: string[];
107
+ environmentRefs?: ResourceRef[];
107
108
  }
108
109
 
109
110
  export function buildPlatformClientProto(input: PlatformClientInput): PlatformClient {
110
111
  const expiresAt = input.expiresAt !== undefined ? toTimestamp(input.expiresAt) : undefined;
112
+ const environmentRefs = input.environmentRefs?.map(r => create(ApiResourceReferenceSchema, { ...r, kind: 53 }));
111
113
  return Object.assign(create(PlatformClientSchema), {
112
114
  apiVersion: "iam.stigmer.ai/v1",
113
115
  kind: "PlatformClient",
@@ -128,6 +130,7 @@ export function buildPlatformClientProto(input: PlatformClientInput): PlatformCl
128
130
  autoGrantOnOrg: input.autoGrantOnOrg,
129
131
  autoGrantRole: input.autoGrantRole,
130
132
  allowedOrigins: input.allowedOrigins,
133
+ environmentRefs,
131
134
  })),
132
135
  }) as PlatformClient;
133
136
  }
package/src/index.ts CHANGED
@@ -41,6 +41,7 @@ export {
41
41
  isUnauthenticated,
42
42
  isPermissionDenied,
43
43
  isRetryable,
44
+ isUnimplemented,
44
45
  type ErrorCategory,
45
46
  isConnectError,
46
47
  classifyError,
@@ -60,6 +61,12 @@ export {
60
61
  isResourceAvailable,
61
62
  } from "./resource-availability.js";
62
63
 
64
+ // Complete update-input mappers (full-spec-replace round-trip safety)
65
+ export {
66
+ toOrganizationUpdateInput,
67
+ toIdentityAccountUpdateInput,
68
+ } from "./update-input.js";
69
+
63
70
  // Authorization config and IAM role utilities
64
71
  export {
65
72
  getGrantableRoles,
@@ -104,6 +111,9 @@ export {
104
111
  type SetCursorMemberKeyEnabledParams,
105
112
  } from "./cursor-accounts.js";
106
113
 
114
+ // Provider standing client (platform operators only, read-only)
115
+ export { ProviderStandingClient } from "./provider-standing.js";
116
+
107
117
  // Search client
108
118
  export {
109
119
  SearchClient,
@@ -231,6 +241,14 @@ export {
231
241
  type HttpServerConfigInput,
232
242
  type ToolApprovalPolicyInput,
233
243
  } from "./gen/mcpserver.js";
244
+ export {
245
+ connectAndWait,
246
+ ConnectStillRunningError,
247
+ CONNECT_POLL_INTERVAL_MS,
248
+ CONNECT_SETTLE_BOUND_MS,
249
+ type ConnectAndWaitOptions,
250
+ type McpServerConnectLane,
251
+ } from "./mcpserver-connect.js";
234
252
  export {
235
253
  OrganizationClient,
236
254
  type OrganizationInput,
@@ -271,6 +289,9 @@ export {
271
289
  resolveToolKind,
272
290
  resolveToolKindByName,
273
291
  normalizeToolResult,
292
+ SHELL_INTENT_ARG_FIELD,
293
+ extractShellIntent,
294
+ shellIntentFromArgs,
274
295
  type ToolResultView,
275
296
  type ToolSearchMatch,
276
297
  type ToolContentBlock,
@@ -287,6 +308,7 @@ export {
287
308
  } from "./execution/file-review-fold.js";
288
309
  export { toDisplayFileChange } from "./execution/to-display-file-change.js";
289
310
  export { SkillClient, type SkillInput } from "./gen/skill.js";
311
+ export { RoutedSkillClient, MAX_INLINE_ARTIFACT_BYTES } from "./skill.js";
290
312
  export {
291
313
  WorkflowClient,
292
314
  type WorkflowInput,
@@ -0,0 +1,159 @@
1
+ import { Code, ConnectError } from "@connectrpc/connect";
2
+ import type { McpServer } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
3
+ import type { ConnectInput } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/io_pb";
4
+ import { ConnectPhase } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/status_pb";
5
+ import { isUnimplemented, wrapError } from "./gen/errors.js";
6
+
7
+ /**
8
+ * The slice of {@link McpServerClient} the connect protocol needs — the
9
+ * async-lane pair plus the blocking fallback. Structural on purpose: the
10
+ * full client satisfies it, and tests can hand in three functions.
11
+ */
12
+ export interface McpServerConnectLane {
13
+ startConnect(input: ConnectInput): Promise<McpServer>;
14
+ connect(input: ConnectInput): Promise<McpServer>;
15
+ get(id: string): Promise<McpServer>;
16
+ }
17
+
18
+ /**
19
+ * How often {@link connectAndWait} re-reads the resource while a connect
20
+ * operation runs. Discovery legitimately takes tens of seconds to minutes;
21
+ * a few seconds of staleness is invisible next to that, and each poll is
22
+ * one cheap get.
23
+ */
24
+ export const CONNECT_POLL_INTERVAL_MS = 2_500;
25
+
26
+ /**
27
+ * Absolute bound on waiting for a connect to settle: the backend's async
28
+ * connect ceiling (its asyncConnectTimeout, 60 min) plus margin. Every
29
+ * operation settles within the ceiling by construction; only a
30
+ * connect_status orphaned by a backend restart can still read CONNECTING
31
+ * past it, and this bound turns that into a typed error instead of an
32
+ * infinite wait.
33
+ */
34
+ export const CONNECT_SETTLE_BOUND_MS = 65 * 60_000;
35
+
36
+ /**
37
+ * Thrown by {@link connectAndWait} when it stopped waiting while the
38
+ * server-side operation was still running. NOT a failure: the backend
39
+ * finishes the connect on its own and persists the result — re-read the
40
+ * resource (or re-run the connect) to observe the outcome.
41
+ */
42
+ export class ConnectStillRunningError extends Error {
43
+ readonly mcpServerId: string;
44
+
45
+ constructor(mcpServerId: string, waitedMs: number) {
46
+ super(
47
+ `the connect of MCP server '${mcpServerId}' is still running server-side after ${Math.round(waitedMs / 1000)}s — ` +
48
+ "it will persist its result on its own; re-read the server to observe the outcome",
49
+ );
50
+ this.name = "ConnectStillRunningError";
51
+ this.mcpServerId = mcpServerId;
52
+ }
53
+ }
54
+
55
+ /** Options for {@link connectAndWait}. */
56
+ export interface ConnectAndWaitOptions {
57
+ /** Poll cadence. Defaults to {@link CONNECT_POLL_INTERVAL_MS}. */
58
+ readonly pollIntervalMs?: number;
59
+ /**
60
+ * Stop waiting after this long (soft bound — the server-side operation
61
+ * keeps running). Defaults to {@link CONNECT_SETTLE_BOUND_MS}, and is
62
+ * capped by it: waiting longer than the backend's own ceiling can only
63
+ * ever observe an orphaned record.
64
+ */
65
+ readonly deadlineMs?: number;
66
+ /**
67
+ * Observe the CONNECTING snapshot the moment the operation is accepted —
68
+ * the place to read `status.connect_status.warning` (the dead-runner
69
+ * advisory) before the wait begins. Not called on the blocking fallback,
70
+ * which has no start-time snapshot.
71
+ */
72
+ readonly onStarted?: (started: McpServer) => void;
73
+ }
74
+
75
+ /**
76
+ * Connect an MCP server and wait for the operation to settle, without any
77
+ * long-lived RPC (stigmer/stigmer#425).
78
+ *
79
+ * Uses the async lane — `startConnect` returns immediately with
80
+ * `status.connect_status = CONNECTING`, then the resource is polled until
81
+ * the operation settles — so the wait survives transport limits that kill
82
+ * a long-blocking unary call (browsers drop no-bytes responses around
83
+ * ~300s, below the server's discovery ceiling). Callers never see the
84
+ * mechanics: the promise resolves with the updated server exactly as the
85
+ * blocking `connect` RPC resolved, and a failed operation rejects with the
86
+ * same {@link StigmerError} classification the blocking RPC would have
87
+ * thrown (`connect_status.failure_code` is the Go gRPC code name, which
88
+ * matches connect-es `Code` member names — rehydration is lossless).
89
+ *
90
+ * Backends that predate the async lane answer UNIMPLEMENTED for
91
+ * `startConnect`; this falls back to the blocking `connect` RPC — the same
92
+ * edition capability-probe idiom as the skill artifact-transfer lane
93
+ * (skill.ts) and the org-OAuth-app surface.
94
+ */
95
+ export async function connectAndWait(
96
+ client: McpServerConnectLane,
97
+ input: ConnectInput,
98
+ options?: ConnectAndWaitOptions,
99
+ ): Promise<McpServer> {
100
+ const pollIntervalMs = options?.pollIntervalMs ?? CONNECT_POLL_INTERVAL_MS;
101
+ const waitMs = Math.min(options?.deadlineMs ?? CONNECT_SETTLE_BOUND_MS, CONNECT_SETTLE_BOUND_MS);
102
+
103
+ let started: McpServer;
104
+ try {
105
+ started = await client.startConnect(input);
106
+ } catch (err) {
107
+ if (!isUnimplemented(err)) throw err;
108
+ return blockingConnect(client, input, waitMs);
109
+ }
110
+ options?.onStarted?.(started);
111
+
112
+ const deadline = Date.now() + waitMs;
113
+ for (;;) {
114
+ if (Date.now() >= deadline) {
115
+ throw new ConnectStillRunningError(input.mcpServerId, waitMs);
116
+ }
117
+ await sleep(Math.min(pollIntervalMs, Math.max(1, deadline - Date.now())));
118
+
119
+ const current = await client.get(input.mcpServerId);
120
+ const cs = current.status?.connectStatus;
121
+ if (cs?.phase === ConnectPhase.succeeded) return current;
122
+ if (cs?.phase === ConnectPhase.failed) {
123
+ throw rehydrateConnectFailure(cs.failureCode, cs.failureMessage);
124
+ }
125
+ }
126
+ }
127
+
128
+ // The pre-async-lane path, kept behaviorally identical for old backends: one
129
+ // blocking RPC, raced (not cancelled — the server finishes and persists on
130
+ // its own) against the caller's soft bound.
131
+ async function blockingConnect(client: McpServerConnectLane, input: ConnectInput, waitMs: number): Promise<McpServer> {
132
+ const push = client.connect(input);
133
+ // The losing push may settle after the caller has moved on; swallow its
134
+ // late rejection so it cannot surface as an unhandled-rejection crash.
135
+ void push.catch(() => {});
136
+
137
+ let timer: ReturnType<typeof setTimeout> | undefined;
138
+ const timeout = new Promise<never>((_, reject) => {
139
+ timer = setTimeout(() => reject(new ConnectStillRunningError(input.mcpServerId, waitMs)), waitMs);
140
+ });
141
+ try {
142
+ return await Promise.race([push, timeout]);
143
+ } finally {
144
+ if (timer !== undefined) clearTimeout(timer);
145
+ }
146
+ }
147
+
148
+ // Rebuild the failure the blocking connect RPC would have thrown, from the
149
+ // classification the backend persisted on connect_status. Routing the
150
+ // rehydrated ConnectError through wrapError makes the result byte-identical
151
+ // to a live RPC failure (same StigmerError code mapping, same raw message).
152
+ function rehydrateConnectFailure(failureCode: string, failureMessage: string) {
153
+ const code = (Code as Record<string, unknown>)[failureCode];
154
+ return wrapError(new ConnectError(failureMessage, typeof code === "number" ? (code as Code) : Code.Unknown));
155
+ }
156
+
157
+ function sleep(ms: number): Promise<void> {
158
+ return new Promise((resolve) => setTimeout(resolve, ms));
159
+ }
@@ -0,0 +1,37 @@
1
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
2
+ import { create } from "@bufbuild/protobuf";
3
+ import { ProviderStandingQueryController } from "@stigmer/protos/ai/stigmer/platform/providerstanding/v1/query_pb";
4
+ import {
5
+ GetProviderStandingViewInputSchema,
6
+ type ProviderStandingView,
7
+ } from "@stigmer/protos/ai/stigmer/platform/providerstanding/v1/io_pb";
8
+ import { wrapError } from "./gen/errors.js";
9
+
10
+ /**
11
+ * Client for platform provider standing (platform operators only).
12
+ *
13
+ * Serves the read-only operator view of the platform's LLM provider
14
+ * account health: the latest canary-probe verdict per provider (status,
15
+ * HTTP status, latency, bounded error summary, probe time) recorded by
16
+ * the hourly standing probe. Requires `can_view_provider_standing` on
17
+ * `platform:stigmer`. Cloud-only — the OSS Go server does not implement
18
+ * this controller.
19
+ */
20
+ export class ProviderStandingClient {
21
+ private readonly query: Client<typeof ProviderStandingQueryController>;
22
+
23
+ constructor(transport: Transport) {
24
+ this.query = createClient(ProviderStandingQueryController, transport);
25
+ }
26
+
27
+ /** Retrieve the latest probe verdict for every platform provider. */
28
+ async getStandingView(): Promise<ProviderStandingView> {
29
+ try {
30
+ return await this.query.getProviderStandingView(
31
+ create(GetProviderStandingViewInputSchema, {}),
32
+ );
33
+ } catch (e) {
34
+ throw wrapError(e);
35
+ }
36
+ }
37
+ }