@stigmer/sdk 0.0.36

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 (138) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +199 -0
  3. package/config.d.ts +40 -0
  4. package/config.d.ts.map +1 -0
  5. package/config.js +17 -0
  6. package/config.js.map +1 -0
  7. package/errors.d.ts +77 -0
  8. package/errors.d.ts.map +1 -0
  9. package/errors.js +163 -0
  10. package/errors.js.map +1 -0
  11. package/gen/agent.d.ts +56 -0
  12. package/gen/agent.d.ts.map +1 -0
  13. package/gen/agent.js +113 -0
  14. package/gen/agent.js.map +1 -0
  15. package/gen/agentexecution.d.ts +68 -0
  16. package/gen/agentexecution.d.ts.map +1 -0
  17. package/gen/agentexecution.js +197 -0
  18. package/gen/agentexecution.js.map +1 -0
  19. package/gen/agentinstance.d.ts +26 -0
  20. package/gen/agentinstance.d.ts.map +1 -0
  21. package/gen/agentinstance.js +92 -0
  22. package/gen/agentinstance.js.map +1 -0
  23. package/gen/apikey.d.ts +25 -0
  24. package/gen/apikey.d.ts.map +1 -0
  25. package/gen/apikey.js +85 -0
  26. package/gen/apikey.js.map +1 -0
  27. package/gen/client.d.ts +76 -0
  28. package/gen/client.d.ts.map +1 -0
  29. package/gen/client.js +77 -0
  30. package/gen/client.js.map +1 -0
  31. package/gen/environment.d.ts +23 -0
  32. package/gen/environment.d.ts.map +1 -0
  33. package/gen/environment.js +86 -0
  34. package/gen/environment.js.map +1 -0
  35. package/gen/errors.d.ts +15 -0
  36. package/gen/errors.d.ts.map +1 -0
  37. package/gen/errors.js +52 -0
  38. package/gen/errors.js.map +1 -0
  39. package/gen/executioncontext.d.ts +24 -0
  40. package/gen/executioncontext.d.ts.map +1 -0
  41. package/gen/executioncontext.js +87 -0
  42. package/gen/executioncontext.js.map +1 -0
  43. package/gen/iampolicy.d.ts +34 -0
  44. package/gen/iampolicy.d.ts.map +1 -0
  45. package/gen/iampolicy.js +107 -0
  46. package/gen/iampolicy.js.map +1 -0
  47. package/gen/identityaccount.d.ts +35 -0
  48. package/gen/identityaccount.d.ts.map +1 -0
  49. package/gen/identityaccount.js +113 -0
  50. package/gen/identityaccount.js.map +1 -0
  51. package/gen/identityprovider.d.ts +27 -0
  52. package/gen/identityprovider.d.ts.map +1 -0
  53. package/gen/identityprovider.js +90 -0
  54. package/gen/identityprovider.js.map +1 -0
  55. package/gen/mcpserver.d.ts +50 -0
  56. package/gen/mcpserver.d.ts.map +1 -0
  57. package/gen/mcpserver.js +124 -0
  58. package/gen/mcpserver.js.map +1 -0
  59. package/gen/organization.d.ts +31 -0
  60. package/gen/organization.d.ts.map +1 -0
  61. package/gen/organization.js +102 -0
  62. package/gen/organization.js.map +1 -0
  63. package/gen/project.d.ts +24 -0
  64. package/gen/project.d.ts.map +1 -0
  65. package/gen/project.js +84 -0
  66. package/gen/project.js.map +1 -0
  67. package/gen/session.d.ts +49 -0
  68. package/gen/session.d.ts.map +1 -0
  69. package/gen/session.js +94 -0
  70. package/gen/session.js.map +1 -0
  71. package/gen/skill.d.ts +26 -0
  72. package/gen/skill.d.ts.map +1 -0
  73. package/gen/skill.js +101 -0
  74. package/gen/skill.js.map +1 -0
  75. package/gen/types.d.ts +43 -0
  76. package/gen/types.d.ts.map +1 -0
  77. package/gen/types.js +3 -0
  78. package/gen/types.js.map +1 -0
  79. package/gen/workflow.d.ts +51 -0
  80. package/gen/workflow.d.ts.map +1 -0
  81. package/gen/workflow.js +85 -0
  82. package/gen/workflow.js.map +1 -0
  83. package/gen/workflowexecution.d.ts +37 -0
  84. package/gen/workflowexecution.d.ts.map +1 -0
  85. package/gen/workflowexecution.js +161 -0
  86. package/gen/workflowexecution.js.map +1 -0
  87. package/gen/workflowinstance.d.ts +26 -0
  88. package/gen/workflowinstance.d.ts.map +1 -0
  89. package/gen/workflowinstance.js +92 -0
  90. package/gen/workflowinstance.js.map +1 -0
  91. package/index.d.ts +23 -0
  92. package/index.d.ts.map +1 -0
  93. package/index.js +26 -0
  94. package/index.js.map +1 -0
  95. package/internal/interceptors.d.ts +25 -0
  96. package/internal/interceptors.d.ts.map +1 -0
  97. package/internal/interceptors.js +75 -0
  98. package/internal/interceptors.js.map +1 -0
  99. package/package.json +40 -0
  100. package/search.d.ts +41 -0
  101. package/search.d.ts.map +1 -0
  102. package/search.js +45 -0
  103. package/search.js.map +1 -0
  104. package/src/config.ts +64 -0
  105. package/src/errors.ts +219 -0
  106. package/src/gen/agent.ts +146 -0
  107. package/src/gen/agentexecution.ts +205 -0
  108. package/src/gen/agentinstance.ts +91 -0
  109. package/src/gen/apikey.ts +86 -0
  110. package/src/gen/client.ts +99 -0
  111. package/src/gen/environment.ts +86 -0
  112. package/src/gen/errors.ts +74 -0
  113. package/src/gen/executioncontext.ts +87 -0
  114. package/src/gen/iampolicy.ts +108 -0
  115. package/src/gen/identityaccount.ts +115 -0
  116. package/src/gen/identityprovider.ts +94 -0
  117. package/src/gen/mcpserver.ts +147 -0
  118. package/src/gen/organization.ts +103 -0
  119. package/src/gen/project.ts +85 -0
  120. package/src/gen/session.ts +120 -0
  121. package/src/gen/skill.ts +102 -0
  122. package/src/gen/types.ts +51 -0
  123. package/src/gen/workflow.ts +116 -0
  124. package/src/gen/workflowexecution.ts +147 -0
  125. package/src/gen/workflowinstance.ts +91 -0
  126. package/src/index.ts +124 -0
  127. package/src/internal/interceptors.ts +83 -0
  128. package/src/search.ts +71 -0
  129. package/src/stigmer.ts +83 -0
  130. package/src/transport.ts +46 -0
  131. package/stigmer.d.ts +57 -0
  132. package/stigmer.d.ts.map +1 -0
  133. package/stigmer.js +64 -0
  134. package/stigmer.js.map +1 -0
  135. package/transport.d.ts +13 -0
  136. package/transport.d.ts.map +1 -0
  137. package/transport.js +34 -0
  138. package/transport.js.map +1 -0
@@ -0,0 +1,116 @@
1
+ // Code generated by stigmer-codegen. DO NOT EDIT.
2
+
3
+ import { wrapError } from "./errors";
4
+ import { type EnvSpecInput, type ResourceRef } from "./types";
5
+ import { create, type JsonObject } from "@bufbuild/protobuf";
6
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
7
+ import { WorkflowSchema, type Workflow } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
8
+ import { WorkflowCommandController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/command_pb";
9
+ import { WorkflowTaskKind } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/enum_pb";
10
+ import { WorkflowIdSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/io_pb";
11
+ import { WorkflowQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/query_pb";
12
+ import { WorkflowSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/spec_pb";
13
+ import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
14
+ import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
15
+
16
+ /** Provides operations on workflow resources. */
17
+ export class WorkflowClient {
18
+ private readonly command: Client<typeof WorkflowCommandController>;
19
+ private readonly query: Client<typeof WorkflowQueryController>;
20
+
21
+ constructor(transport: Transport) {
22
+ this.command = createClient(WorkflowCommandController, transport);
23
+ this.query = createClient(WorkflowQueryController, transport);
24
+ }
25
+
26
+ async apply(input: WorkflowInput): Promise<Workflow> {
27
+ try {
28
+ return await this.command.apply(buildWorkflowProto(input));
29
+ } catch (e) { throw wrapError(e); }
30
+ }
31
+
32
+ async create(input: WorkflowInput): Promise<Workflow> {
33
+ try {
34
+ return await this.command.create(buildWorkflowProto(input));
35
+ } catch (e) { throw wrapError(e); }
36
+ }
37
+
38
+ async update(input: WorkflowInput): Promise<Workflow> {
39
+ try {
40
+ return await this.command.update(buildWorkflowProto(input));
41
+ } catch (e) { throw wrapError(e); }
42
+ }
43
+
44
+ async delete(id: string): Promise<Workflow> {
45
+ try {
46
+ return await this.command.delete(create(WorkflowIdSchema, { value: id }));
47
+ } catch (e) { throw wrapError(e); }
48
+ }
49
+
50
+ async get(id: string): Promise<Workflow> {
51
+ try {
52
+ return await this.query.get(create(WorkflowIdSchema, { value: id }));
53
+ } catch (e) { throw wrapError(e); }
54
+ }
55
+
56
+ async getByReference(ref: ResourceRef): Promise<Workflow> {
57
+ try {
58
+ return await this.query.getByReference(create(ApiResourceReferenceSchema, ref));
59
+ } catch (e) { throw wrapError(e); }
60
+ }
61
+ }
62
+
63
+ /** Input for creating/updating a Workflow. */
64
+ export interface WorkflowInput {
65
+ name: string;
66
+ org: string;
67
+ description?: string;
68
+ document: WorkflowDocumentInput;
69
+ tasks?: WorkflowTaskInput[];
70
+ envSpec?: EnvSpecInput;
71
+ }
72
+
73
+ /** SDK input type for WorkflowDocument. */
74
+ export interface WorkflowDocumentInput {
75
+ dsl?: string;
76
+ namespace: string;
77
+ name: string;
78
+ version: string;
79
+ description?: string;
80
+ }
81
+
82
+ /** SDK input type for WorkflowTask. */
83
+ export interface WorkflowTaskInput {
84
+ name: string;
85
+ kind: WorkflowTaskKind;
86
+ taskConfig: JsonObject;
87
+ export?: ExportInput;
88
+ flow?: FlowControlInput;
89
+ }
90
+
91
+ /** SDK input type for Export. */
92
+ export interface ExportInput {
93
+ as?: string;
94
+ }
95
+
96
+ /** SDK input type for FlowControl. */
97
+ export interface FlowControlInput {
98
+ then?: string;
99
+ }
100
+
101
+ function buildWorkflowProto(input: WorkflowInput): Workflow {
102
+ return Object.assign(create(WorkflowSchema), {
103
+ apiVersion: "agentic.stigmer.ai/v1",
104
+ kind: "Workflow",
105
+ metadata: Object.assign(create(ApiResourceMetadataSchema), {
106
+ name: input.name,
107
+ org: input.org,
108
+ }),
109
+ spec: Object.assign(create(WorkflowSpecSchema), {
110
+ description: input.description,
111
+ document: input.document,
112
+ tasks: input.tasks,
113
+ envSpec: input.envSpec,
114
+ }),
115
+ }) as Workflow;
116
+ }
@@ -0,0 +1,147 @@
1
+ // Code generated by stigmer-codegen. DO NOT EDIT.
2
+
3
+ import { wrapError } from "./errors";
4
+ import { type EnvVarInput } from "./types";
5
+ import { create } from "@bufbuild/protobuf";
6
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
7
+ import { WorkflowExecutionSchema, type WorkflowExecution } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
8
+ import { WorkflowExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/command_pb";
9
+ import { WorkflowExecutionIdSchema, WorkflowExecutionUpdateStatusInputSchema, SubmitWorkflowApprovalInputSchema, SendSignalInputSchema, CancelWorkflowExecutionInputSchema, TerminateWorkflowExecutionInputSchema, RecoverWorkflowExecutionInputSchema, PauseWorkflowExecutionInputSchema, ResumeWorkflowExecutionInputSchema, ListWorkflowExecutionsRequestSchema, WorkflowExecutionListSchema, ListWorkflowExecutionsByWorkflowRequestSchema, SubscribeWorkflowExecutionRequestSchema, type WorkflowExecutionUpdateStatusInput, type SubmitWorkflowApprovalInput, type SendSignalInput, type CancelWorkflowExecutionInput, type TerminateWorkflowExecutionInput, type RecoverWorkflowExecutionInput, type PauseWorkflowExecutionInput, type ResumeWorkflowExecutionInput, type ListWorkflowExecutionsRequest, type WorkflowExecutionList, type ListWorkflowExecutionsByWorkflowRequest, type SubscribeWorkflowExecutionRequest } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/io_pb";
10
+ import { WorkflowExecutionQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/query_pb";
11
+ import { WorkflowExecutionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/spec_pb";
12
+ import { ApiResourceIdSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
13
+ import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
14
+
15
+ /** Provides operations on workflowexecution resources. */
16
+ export class WorkflowExecutionClient {
17
+ private readonly command: Client<typeof WorkflowExecutionCommandController>;
18
+ private readonly query: Client<typeof WorkflowExecutionQueryController>;
19
+
20
+ constructor(transport: Transport) {
21
+ this.command = createClient(WorkflowExecutionCommandController, transport);
22
+ this.query = createClient(WorkflowExecutionQueryController, transport);
23
+ }
24
+
25
+ async create(input: WorkflowExecutionInput): Promise<WorkflowExecution> {
26
+ try {
27
+ return await this.command.create(buildWorkflowExecutionProto(input));
28
+ } catch (e) { throw wrapError(e); }
29
+ }
30
+
31
+ async update(input: WorkflowExecutionInput): Promise<WorkflowExecution> {
32
+ try {
33
+ return await this.command.update(buildWorkflowExecutionProto(input));
34
+ } catch (e) { throw wrapError(e); }
35
+ }
36
+
37
+ async updateStatus(input: WorkflowExecutionUpdateStatusInput): Promise<WorkflowExecution> {
38
+ try {
39
+ return await this.command.updateStatus(input);
40
+ } catch (e) { throw wrapError(e); }
41
+ }
42
+
43
+ async submitApproval(input: SubmitWorkflowApprovalInput): Promise<WorkflowExecution> {
44
+ try {
45
+ return await this.command.submitApproval(input);
46
+ } catch (e) { throw wrapError(e); }
47
+ }
48
+
49
+ async delete(id: string): Promise<WorkflowExecution> {
50
+ try {
51
+ return await this.command.delete(create(ApiResourceIdSchema, { value: id }));
52
+ } catch (e) { throw wrapError(e); }
53
+ }
54
+
55
+ async sendSignal(input: SendSignalInput): Promise<WorkflowExecution> {
56
+ try {
57
+ return await this.command.sendSignal(input);
58
+ } catch (e) { throw wrapError(e); }
59
+ }
60
+
61
+ async cancel(input: CancelWorkflowExecutionInput): Promise<WorkflowExecution> {
62
+ try {
63
+ return await this.command.cancel(input);
64
+ } catch (e) { throw wrapError(e); }
65
+ }
66
+
67
+ async terminate(input: TerminateWorkflowExecutionInput): Promise<WorkflowExecution> {
68
+ try {
69
+ return await this.command.terminate(input);
70
+ } catch (e) { throw wrapError(e); }
71
+ }
72
+
73
+ async recover(input: RecoverWorkflowExecutionInput): Promise<WorkflowExecution> {
74
+ try {
75
+ return await this.command.recover(input);
76
+ } catch (e) { throw wrapError(e); }
77
+ }
78
+
79
+ async pause(input: PauseWorkflowExecutionInput): Promise<WorkflowExecution> {
80
+ try {
81
+ return await this.command.pause(input);
82
+ } catch (e) { throw wrapError(e); }
83
+ }
84
+
85
+ async resume(input: ResumeWorkflowExecutionInput): Promise<WorkflowExecution> {
86
+ try {
87
+ return await this.command.resume(input);
88
+ } catch (e) { throw wrapError(e); }
89
+ }
90
+
91
+ async get(id: string): Promise<WorkflowExecution> {
92
+ try {
93
+ return await this.query.get(create(WorkflowExecutionIdSchema, { value: id }));
94
+ } catch (e) { throw wrapError(e); }
95
+ }
96
+
97
+ async list(input: ListWorkflowExecutionsRequest): Promise<WorkflowExecutionList> {
98
+ try {
99
+ return await this.query.list(input);
100
+ } catch (e) { throw wrapError(e); }
101
+ }
102
+
103
+ async listByWorkflow(input: ListWorkflowExecutionsByWorkflowRequest): Promise<WorkflowExecutionList> {
104
+ try {
105
+ return await this.query.listByWorkflow(input);
106
+ } catch (e) { throw wrapError(e); }
107
+ }
108
+
109
+ async *subscribe(input: SubscribeWorkflowExecutionRequest, signal?: AbortSignal): AsyncGenerator<WorkflowExecution> {
110
+ try {
111
+ for await (const msg of this.query.subscribe(input, { signal })) {
112
+ yield msg;
113
+ }
114
+ } catch (e) { throw wrapError(e); }
115
+ }
116
+ }
117
+
118
+ /** Input for creating/updating a WorkflowExecution. */
119
+ export interface WorkflowExecutionInput {
120
+ name: string;
121
+ org: string;
122
+ workflowInstanceId?: string;
123
+ workflowId?: string;
124
+ triggerMessage?: string;
125
+ triggerMetadata?: Record<string, string>;
126
+ runtimeEnv?: Record<string, EnvVarInput>;
127
+ callbackToken?: Uint8Array;
128
+ }
129
+
130
+ function buildWorkflowExecutionProto(input: WorkflowExecutionInput): WorkflowExecution {
131
+ return Object.assign(create(WorkflowExecutionSchema), {
132
+ apiVersion: "agentic.stigmer.ai/v1",
133
+ kind: "WorkflowExecution",
134
+ metadata: Object.assign(create(ApiResourceMetadataSchema), {
135
+ name: input.name,
136
+ org: input.org,
137
+ }),
138
+ spec: Object.assign(create(WorkflowExecutionSpecSchema), {
139
+ workflowInstanceId: input.workflowInstanceId,
140
+ workflowId: input.workflowId,
141
+ triggerMessage: input.triggerMessage,
142
+ triggerMetadata: input.triggerMetadata,
143
+ runtimeEnv: input.runtimeEnv,
144
+ callbackToken: input.callbackToken,
145
+ }),
146
+ }) as WorkflowExecution;
147
+ }
@@ -0,0 +1,91 @@
1
+ // Code generated by stigmer-codegen. DO NOT EDIT.
2
+
3
+ import { wrapError } from "./errors";
4
+ import { type ResourceRef } from "./types";
5
+ import { create } from "@bufbuild/protobuf";
6
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
7
+ import { WorkflowInstanceSchema, type WorkflowInstance } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/api_pb";
8
+ import { WorkflowInstanceCommandController } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/command_pb";
9
+ import { WorkflowInstanceIdSchema, GetWorkflowInstancesByWorkflowRequestSchema, WorkflowInstanceListSchema, type GetWorkflowInstancesByWorkflowRequest, type WorkflowInstanceList } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/io_pb";
10
+ import { WorkflowInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/query_pb";
11
+ import { WorkflowInstanceSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/spec_pb";
12
+ import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
13
+ import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
14
+
15
+ /** Provides operations on workflowinstance resources. */
16
+ export class WorkflowInstanceClient {
17
+ private readonly command: Client<typeof WorkflowInstanceCommandController>;
18
+ private readonly query: Client<typeof WorkflowInstanceQueryController>;
19
+
20
+ constructor(transport: Transport) {
21
+ this.command = createClient(WorkflowInstanceCommandController, transport);
22
+ this.query = createClient(WorkflowInstanceQueryController, transport);
23
+ }
24
+
25
+ async apply(input: WorkflowInstanceInput): Promise<WorkflowInstance> {
26
+ try {
27
+ return await this.command.apply(buildWorkflowInstanceProto(input));
28
+ } catch (e) { throw wrapError(e); }
29
+ }
30
+
31
+ async create(input: WorkflowInstanceInput): Promise<WorkflowInstance> {
32
+ try {
33
+ return await this.command.create(buildWorkflowInstanceProto(input));
34
+ } catch (e) { throw wrapError(e); }
35
+ }
36
+
37
+ async update(input: WorkflowInstanceInput): Promise<WorkflowInstance> {
38
+ try {
39
+ return await this.command.update(buildWorkflowInstanceProto(input));
40
+ } catch (e) { throw wrapError(e); }
41
+ }
42
+
43
+ async delete(id: string): Promise<WorkflowInstance> {
44
+ try {
45
+ return await this.command.delete(create(WorkflowInstanceIdSchema, { value: id }));
46
+ } catch (e) { throw wrapError(e); }
47
+ }
48
+
49
+ async get(id: string): Promise<WorkflowInstance> {
50
+ try {
51
+ return await this.query.get(create(WorkflowInstanceIdSchema, { value: id }));
52
+ } catch (e) { throw wrapError(e); }
53
+ }
54
+
55
+ async getByWorkflow(input: GetWorkflowInstancesByWorkflowRequest): Promise<WorkflowInstanceList> {
56
+ try {
57
+ return await this.query.getByWorkflow(input);
58
+ } catch (e) { throw wrapError(e); }
59
+ }
60
+
61
+ async getByReference(ref: ResourceRef): Promise<WorkflowInstance> {
62
+ try {
63
+ return await this.query.getByReference(create(ApiResourceReferenceSchema, ref));
64
+ } catch (e) { throw wrapError(e); }
65
+ }
66
+ }
67
+
68
+ /** Input for creating/updating a WorkflowInstance. */
69
+ export interface WorkflowInstanceInput {
70
+ name: string;
71
+ org: string;
72
+ workflowId?: string;
73
+ description?: string;
74
+ envRefs?: ResourceRef[];
75
+ }
76
+
77
+ function buildWorkflowInstanceProto(input: WorkflowInstanceInput): WorkflowInstance {
78
+ return Object.assign(create(WorkflowInstanceSchema), {
79
+ apiVersion: "agentic.stigmer.ai/v1",
80
+ kind: "WorkflowInstance",
81
+ metadata: Object.assign(create(ApiResourceMetadataSchema), {
82
+ name: input.name,
83
+ org: input.org,
84
+ }),
85
+ spec: Object.assign(create(WorkflowInstanceSpecSchema), {
86
+ workflowId: input.workflowId,
87
+ description: input.description,
88
+ envRefs: input.envRefs,
89
+ }),
90
+ }) as WorkflowInstance;
91
+ }
package/src/index.ts ADDED
@@ -0,0 +1,124 @@
1
+ // Public API for @stigmer/sdk
2
+
3
+ // Top-level client
4
+ export { Stigmer } from "./stigmer";
5
+
6
+ // Configuration
7
+ export { type StigmerConfig, type TokenProvider } from "./config";
8
+
9
+ // Error handling
10
+ export {
11
+ StigmerError,
12
+ type ErrorCode,
13
+ isNotFound,
14
+ isUnauthenticated,
15
+ isPermissionDenied,
16
+ isRetryable,
17
+ type ErrorCategory,
18
+ isConnectError,
19
+ classifyError,
20
+ isRetryableError,
21
+ getUserMessage,
22
+ type RpcErrorMetadata,
23
+ annotateRpcError,
24
+ getRpcMetadata,
25
+ } from "./errors";
26
+
27
+ // Search client
28
+ export {
29
+ SearchClient,
30
+ type SearchParams,
31
+ type SearchResponse,
32
+ ApiResourceKind,
33
+ } from "./search";
34
+
35
+ // Shared types (from generated code)
36
+ export {
37
+ type DeleteResourceInput,
38
+ type ResourceRef,
39
+ type Page,
40
+ type ListParams,
41
+ type ListResult,
42
+ type EnvSpecInput,
43
+ type EnvVarInput,
44
+ } from "./gen/types";
45
+
46
+ // Re-export all resource client classes and input types
47
+ export {
48
+ AgentClient,
49
+ type AgentInput,
50
+ type McpServerUsageInput,
51
+ type ToolApprovalOverrideInput,
52
+ type SubAgentInput,
53
+ type McpAccessInput,
54
+ } from "./gen/agent";
55
+ export {
56
+ AgentExecutionClient,
57
+ type AgentExecutionInput,
58
+ type ExecutionConfigInput,
59
+ type ContextManagementConfigInput,
60
+ type AttachmentInput,
61
+ } from "./gen/agentexecution";
62
+ export {
63
+ AgentInstanceClient,
64
+ type AgentInstanceInput,
65
+ } from "./gen/agentinstance";
66
+ export { ApiKeyClient, type ApiKeyInput } from "./gen/apikey";
67
+ export {
68
+ EnvironmentClient,
69
+ type EnvironmentInput,
70
+ } from "./gen/environment";
71
+ export {
72
+ ExecutionContextClient,
73
+ type ExecutionContextInput,
74
+ } from "./gen/executioncontext";
75
+ export {
76
+ IamPolicyClient,
77
+ type IamPolicyInput,
78
+ type ApiResourceRefInput,
79
+ } from "./gen/iampolicy";
80
+ export {
81
+ IdentityAccountClient,
82
+ type IdentityAccountInput,
83
+ } from "./gen/identityaccount";
84
+ export {
85
+ IdentityProviderClient,
86
+ type IdentityProviderInput,
87
+ } from "./gen/identityprovider";
88
+ export {
89
+ McpServerClient,
90
+ type McpServerInput,
91
+ type StdioServerConfigInput,
92
+ type HttpServerConfigInput,
93
+ type ToolApprovalPolicyInput,
94
+ } from "./gen/mcpserver";
95
+ export {
96
+ OrganizationClient,
97
+ type OrganizationInput,
98
+ } from "./gen/organization";
99
+ export { ProjectClient, type ProjectInput } from "./gen/project";
100
+ export {
101
+ SessionClient,
102
+ type SessionInput,
103
+ type WorkspaceEntryInput,
104
+ type WorkspaceSourceInput,
105
+ type GitRepoSourceInput,
106
+ type LocalPathSourceInput,
107
+ } from "./gen/session";
108
+ export { SkillClient, type SkillInput } from "./gen/skill";
109
+ export {
110
+ WorkflowClient,
111
+ type WorkflowInput,
112
+ type WorkflowDocumentInput,
113
+ type WorkflowTaskInput,
114
+ type ExportInput,
115
+ type FlowControlInput,
116
+ } from "./gen/workflow";
117
+ export {
118
+ WorkflowExecutionClient,
119
+ type WorkflowExecutionInput,
120
+ } from "./gen/workflowexecution";
121
+ export {
122
+ WorkflowInstanceClient,
123
+ type WorkflowInstanceInput,
124
+ } from "./gen/workflowinstance";
@@ -0,0 +1,83 @@
1
+ import { ConnectError, Code, type Interceptor } from "@connectrpc/connect";
2
+ import type { TokenProvider } from "../config";
3
+ import { annotateRpcError } from "../errors";
4
+
5
+ /**
6
+ * Create an interceptor that attaches `Authorization: Bearer <token>` to
7
+ * every outgoing request. Supports both static API keys and dynamic token
8
+ * providers.
9
+ */
10
+ export function createAuthInterceptor(
11
+ getAccessToken: TokenProvider,
12
+ ): Interceptor {
13
+ return (next) => async (request) => {
14
+ const token = await getAccessToken();
15
+ if (token) {
16
+ request.header.set("Authorization", `Bearer ${token}`);
17
+ }
18
+ return next(request);
19
+ };
20
+ }
21
+
22
+ /**
23
+ * Interceptor that annotates every error with the RPC method name and
24
+ * service path that produced it. Must run before error-transforming
25
+ * interceptors so the raw request context is available.
26
+ */
27
+ export const rpcMetadataInterceptor: Interceptor =
28
+ (next) => async (request) => {
29
+ try {
30
+ return await next(request);
31
+ } catch (error: unknown) {
32
+ if (error !== null && typeof error === "object") {
33
+ const segments = request.url.split("/");
34
+ const method = segments.at(-1) ?? "";
35
+ const service = segments.at(-2) ?? "";
36
+ annotateRpcError(error, {
37
+ method: method.charAt(0).toLowerCase() + method.slice(1),
38
+ path: `/${service}/${method}`,
39
+ });
40
+ }
41
+ throw error;
42
+ }
43
+ };
44
+
45
+ /**
46
+ * Interceptor that strips gRPC status-code prefixes (e.g., `[internal]`)
47
+ * from error messages. The structured code remains on `ConnectError.code`.
48
+ */
49
+ export const errorStripInterceptor: Interceptor = (next) => async (request) => {
50
+ try {
51
+ return await next(request);
52
+ } catch (error: unknown) {
53
+ if (error instanceof Error && error.message) {
54
+ error.message = error.message.replace(/^\[.*?]\s*/, "");
55
+ }
56
+ throw error;
57
+ }
58
+ };
59
+
60
+ /**
61
+ * Create an interceptor that invokes a callback on UNAUTHENTICATED (code 16).
62
+ * The callback fires at most once per client to prevent cascading redirects.
63
+ */
64
+ export function createAuthRedirectInterceptor(
65
+ onUnauthenticated: () => void,
66
+ ): Interceptor {
67
+ let fired = false;
68
+ return (next) => async (request) => {
69
+ try {
70
+ return await next(request);
71
+ } catch (error: unknown) {
72
+ if (
73
+ !fired &&
74
+ error instanceof ConnectError &&
75
+ error.code === Code.Unauthenticated
76
+ ) {
77
+ fired = true;
78
+ onUnauthenticated();
79
+ }
80
+ throw error;
81
+ }
82
+ };
83
+ }
package/src/search.ts ADDED
@@ -0,0 +1,71 @@
1
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
2
+ import { create } from "@bufbuild/protobuf";
3
+ import { SearchService } from "@stigmer/protos/ai/stigmer/search/v1/query_pb";
4
+ import { SearchRequestSchema } from "@stigmer/protos/ai/stigmer/search/v1/io_pb";
5
+ import { PageInfoSchema } from "@stigmer/protos/ai/stigmer/commons/rpc/pagination_pb";
6
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
7
+ import type { SearchResult } from "@stigmer/protos/ai/stigmer/search/v1/io_pb";
8
+ import { wrapError } from "./gen/errors";
9
+
10
+ /** Re-export ApiResourceKind for use with SearchClient. */
11
+ export { ApiResourceKind };
12
+
13
+ /** Parameters for a cross-resource search query. */
14
+ export interface SearchParams {
15
+ /** Resource kinds to include in the search. */
16
+ readonly kinds: ApiResourceKind[];
17
+ /** Organization slug to scope the query. */
18
+ readonly org: string;
19
+ /** Free-text search query. */
20
+ readonly query?: string;
21
+ /** Whether to exclude public (non-org) resources from results. */
22
+ readonly excludePublic?: boolean;
23
+ /** Pagination parameters. */
24
+ readonly page?: { num: number; size: number };
25
+ }
26
+
27
+ /** A page of cross-resource search results. */
28
+ export interface SearchResponse {
29
+ readonly entries: SearchResult[];
30
+ readonly totalCount: number;
31
+ readonly totalPages: number;
32
+ }
33
+
34
+ /**
35
+ * Cross-resource search client.
36
+ *
37
+ * Unlike the per-resource `list()` methods (which search within a single
38
+ * resource kind), `SearchClient.query()` searches across multiple resource
39
+ * kinds in a single call.
40
+ */
41
+ export class SearchClient {
42
+ private readonly search: Client<typeof SearchService>;
43
+
44
+ constructor(transport: Transport) {
45
+ this.search = createClient(SearchService, transport);
46
+ }
47
+
48
+ /** Perform a cross-resource search. */
49
+ async query(params: SearchParams): Promise<SearchResponse> {
50
+ try {
51
+ const resp = await this.search.search(
52
+ create(SearchRequestSchema, {
53
+ kinds: params.kinds,
54
+ query: params.query,
55
+ org: params.org,
56
+ excludePublic: params.excludePublic ?? false,
57
+ page: params.page
58
+ ? create(PageInfoSchema, params.page)
59
+ : undefined,
60
+ }),
61
+ );
62
+ return {
63
+ entries: resp.entries,
64
+ totalCount: resp.totalCount,
65
+ totalPages: resp.totalPages,
66
+ };
67
+ } catch (e) {
68
+ throw wrapError(e);
69
+ }
70
+ }
71
+ }