@stigmer/sdk 0.0.36 → 0.0.39

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 (131) hide show
  1. package/__tests__/config.test.d.ts +2 -0
  2. package/__tests__/config.test.d.ts.map +1 -0
  3. package/__tests__/config.test.js +35 -0
  4. package/__tests__/config.test.js.map +1 -0
  5. package/__tests__/errors.test.d.ts +2 -0
  6. package/__tests__/errors.test.d.ts.map +1 -0
  7. package/__tests__/errors.test.js +125 -0
  8. package/__tests__/errors.test.js.map +1 -0
  9. package/__tests__/gen/errors.test.d.ts +2 -0
  10. package/__tests__/gen/errors.test.d.ts.map +1 -0
  11. package/__tests__/gen/errors.test.js +97 -0
  12. package/__tests__/gen/errors.test.js.map +1 -0
  13. package/__tests__/gen/proto-utils.test.d.ts +2 -0
  14. package/__tests__/gen/proto-utils.test.d.ts.map +1 -0
  15. package/__tests__/gen/proto-utils.test.js +45 -0
  16. package/__tests__/gen/proto-utils.test.js.map +1 -0
  17. package/__tests__/gen/session-client.test.d.ts +2 -0
  18. package/__tests__/gen/session-client.test.d.ts.map +1 -0
  19. package/__tests__/gen/session-client.test.js +148 -0
  20. package/__tests__/gen/session-client.test.js.map +1 -0
  21. package/gen/agent.d.ts +4 -0
  22. package/gen/agent.d.ts.map +1 -1
  23. package/gen/agent.js +69 -7
  24. package/gen/agent.js.map +1 -1
  25. package/gen/agentexecution.d.ts +4 -1
  26. package/gen/agentexecution.d.ts.map +1 -1
  27. package/gen/agentexecution.js +55 -6
  28. package/gen/agentexecution.js.map +1 -1
  29. package/gen/agentinstance.d.ts +4 -1
  30. package/gen/agentinstance.d.ts.map +1 -1
  31. package/gen/agentinstance.js +15 -3
  32. package/gen/agentinstance.js.map +1 -1
  33. package/gen/apikey.d.ts +2 -0
  34. package/gen/apikey.d.ts.map +1 -1
  35. package/gen/apikey.js +5 -2
  36. package/gen/apikey.js.map +1 -1
  37. package/gen/environment.d.ts +8 -0
  38. package/gen/environment.d.ts.map +1 -1
  39. package/gen/environment.js +43 -4
  40. package/gen/environment.js.map +1 -1
  41. package/gen/executioncontext.d.ts +2 -0
  42. package/gen/executioncontext.d.ts.map +1 -1
  43. package/gen/executioncontext.js +11 -4
  44. package/gen/executioncontext.js.map +1 -1
  45. package/gen/iampolicy.d.ts +2 -0
  46. package/gen/iampolicy.d.ts.map +1 -1
  47. package/gen/iampolicy.js +17 -5
  48. package/gen/iampolicy.js.map +1 -1
  49. package/gen/identityaccount.d.ts +2 -0
  50. package/gen/identityaccount.d.ts.map +1 -1
  51. package/gen/identityaccount.js +8 -3
  52. package/gen/identityaccount.js.map +1 -1
  53. package/gen/identityprovider.d.ts +2 -0
  54. package/gen/identityprovider.d.ts.map +1 -1
  55. package/gen/identityprovider.js +5 -2
  56. package/gen/identityprovider.js.map +1 -1
  57. package/gen/mcpserver.d.ts +2 -0
  58. package/gen/mcpserver.d.ts.map +1 -1
  59. package/gen/mcpserver.js +49 -10
  60. package/gen/mcpserver.js.map +1 -1
  61. package/gen/organization.d.ts +2 -0
  62. package/gen/organization.d.ts.map +1 -1
  63. package/gen/organization.js +8 -3
  64. package/gen/organization.js.map +1 -1
  65. package/gen/project.d.ts +2 -0
  66. package/gen/project.d.ts.map +1 -1
  67. package/gen/project.js +7 -3
  68. package/gen/project.js.map +1 -1
  69. package/gen/proto-utils.d.ts +6 -0
  70. package/gen/proto-utils.d.ts.map +1 -0
  71. package/gen/proto-utils.js +15 -0
  72. package/gen/proto-utils.js.map +1 -0
  73. package/gen/session.d.ts +18 -1
  74. package/gen/session.d.ts.map +1 -1
  75. package/gen/session.js +62 -3
  76. package/gen/session.js.map +1 -1
  77. package/gen/skill.d.ts +4 -1
  78. package/gen/skill.d.ts.map +1 -1
  79. package/gen/skill.js +13 -2
  80. package/gen/skill.js.map +1 -1
  81. package/gen/workflow.d.ts +2 -0
  82. package/gen/workflow.d.ts.map +1 -1
  83. package/gen/workflow.js +53 -6
  84. package/gen/workflow.js.map +1 -1
  85. package/gen/workflowexecution.d.ts +2 -0
  86. package/gen/workflowexecution.d.ts.map +1 -1
  87. package/gen/workflowexecution.js +11 -3
  88. package/gen/workflowexecution.js.map +1 -1
  89. package/gen/workflowinstance.d.ts +3 -1
  90. package/gen/workflowinstance.d.ts.map +1 -1
  91. package/gen/workflowinstance.js +7 -3
  92. package/gen/workflowinstance.js.map +1 -1
  93. package/github.d.ts +38 -0
  94. package/github.d.ts.map +1 -0
  95. package/github.js +51 -0
  96. package/github.js.map +1 -0
  97. package/index.d.ts +1 -0
  98. package/index.d.ts.map +1 -1
  99. package/index.js +2 -0
  100. package/index.js.map +1 -1
  101. package/package.json +2 -2
  102. package/src/__tests__/config.test.ts +52 -0
  103. package/src/__tests__/errors.test.ts +188 -0
  104. package/src/__tests__/gen/errors.test.ts +138 -0
  105. package/src/__tests__/gen/proto-utils.test.ts +53 -0
  106. package/src/__tests__/gen/session-client.test.ts +202 -0
  107. package/src/gen/agent.ts +65 -8
  108. package/src/gen/agentexecution.ts +55 -7
  109. package/src/gen/agentinstance.ts +16 -4
  110. package/src/gen/apikey.ts +7 -2
  111. package/src/gen/environment.ts +39 -4
  112. package/src/gen/executioncontext.ts +14 -4
  113. package/src/gen/iampolicy.ts +19 -4
  114. package/src/gen/identityaccount.ts +10 -3
  115. package/src/gen/identityprovider.ts +7 -2
  116. package/src/gen/mcpserver.ts +53 -10
  117. package/src/gen/organization.ts +10 -4
  118. package/src/gen/project.ts +9 -3
  119. package/src/gen/proto-utils.ts +15 -0
  120. package/src/gen/session.ts +82 -4
  121. package/src/gen/skill.ts +14 -3
  122. package/src/gen/workflow.ts +54 -6
  123. package/src/gen/workflowexecution.ts +14 -3
  124. package/src/gen/workflowinstance.ts +10 -4
  125. package/src/github.ts +89 -0
  126. package/src/index.ts +9 -0
  127. package/src/stigmer.ts +3 -0
  128. package/stigmer.d.ts +2 -0
  129. package/stigmer.d.ts.map +1 -1
  130. package/stigmer.js +3 -0
  131. package/stigmer.js.map +1 -1
@@ -0,0 +1,202 @@
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+ import type { Transport } from "@connectrpc/connect";
3
+ import type { Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
4
+ import { SessionClient, type SessionInput } from "../../gen/session";
5
+
6
+ interface CapturedRequest {
7
+ methodName: string;
8
+ message: unknown;
9
+ }
10
+
11
+ function createCapturingTransport(): {
12
+ transport: Transport;
13
+ captured: CapturedRequest[];
14
+ } {
15
+ const captured: CapturedRequest[] = [];
16
+
17
+ const transport = {
18
+ unary: async (
19
+ method: { name: string },
20
+ _signal: unknown,
21
+ _timeout: unknown,
22
+ _header: unknown,
23
+ message: unknown,
24
+ ) => ({
25
+ header: new Headers(),
26
+ trailer: new Headers(),
27
+ message,
28
+ }),
29
+ stream: async () => {
30
+ throw new Error("streaming not implemented in test transport");
31
+ },
32
+ } as unknown as Transport;
33
+
34
+ const originalUnary = (transport as unknown as Record<string, unknown>).unary as (
35
+ ...args: unknown[]
36
+ ) => Promise<unknown>;
37
+
38
+ (transport as unknown as Record<string, unknown>).unary = async (
39
+ method: { name: string },
40
+ signal: unknown,
41
+ timeout: unknown,
42
+ header: unknown,
43
+ message: unknown,
44
+ ...rest: unknown[]
45
+ ) => {
46
+ captured.push({ methodName: method.name, message });
47
+ return originalUnary(method, signal, timeout, header, message, ...rest);
48
+ };
49
+
50
+ return { transport, captured };
51
+ }
52
+
53
+ describe("SessionClient proto serialization", () => {
54
+ let client: SessionClient;
55
+ let captured: CapturedRequest[];
56
+
57
+ beforeEach(() => {
58
+ const ctx = createCapturingTransport();
59
+ client = new SessionClient(ctx.transport);
60
+ captured = ctx.captured;
61
+ });
62
+
63
+ it("sets apiVersion and kind on the proto", async () => {
64
+ await client.create({ name: "test-session", org: "my-org" });
65
+
66
+ const proto = captured[0].message as Session;
67
+ expect(proto.apiVersion).toBe("agentic.stigmer.ai/v1");
68
+ expect(proto.kind).toBe("Session");
69
+ });
70
+
71
+ it("sets required fields on metadata", async () => {
72
+ await client.create({ name: "my-session", org: "acme" });
73
+
74
+ const proto = captured[0].message as Session;
75
+ expect(proto.metadata?.name).toBe("my-session");
76
+ expect(proto.metadata?.org).toBe("acme");
77
+ });
78
+
79
+ it("sets optional spec fields when provided", async () => {
80
+ const input: SessionInput = {
81
+ name: "s1",
82
+ org: "o1",
83
+ agentInstanceId: "ai-123",
84
+ subject: "Help with deployment",
85
+ threadId: "thread-abc",
86
+ sandboxId: "sandbox-xyz",
87
+ };
88
+
89
+ await client.create(input);
90
+
91
+ const proto = captured[0].message as Session;
92
+ expect(proto.spec?.agentInstanceId).toBe("ai-123");
93
+ expect(proto.spec?.subject).toBe("Help with deployment");
94
+ expect(proto.spec?.threadId).toBe("thread-abc");
95
+ expect(proto.spec?.sandboxId).toBe("sandbox-xyz");
96
+ });
97
+
98
+ it("does not overwrite protobuf defaults when optional fields are omitted", async () => {
99
+ await client.create({ name: "minimal", org: "org" });
100
+
101
+ const proto = captured[0].message as Session;
102
+ expect(proto.spec?.agentInstanceId).toBe("");
103
+ expect(proto.spec?.subject).toBe("");
104
+ expect(proto.spec?.threadId).toBe("");
105
+ expect(proto.spec?.sandboxId).toBe("");
106
+ });
107
+
108
+ it("serializes metadata map when provided", async () => {
109
+ await client.create({
110
+ name: "s1",
111
+ org: "o1",
112
+ metadata: { env: "production", region: "us-east-1" },
113
+ });
114
+
115
+ const proto = captured[0].message as Session;
116
+ expect(proto.spec?.metadata).toEqual({
117
+ env: "production",
118
+ region: "us-east-1",
119
+ });
120
+ });
121
+
122
+ it("serializes workspace entries with git repo source", async () => {
123
+ await client.create({
124
+ name: "s1",
125
+ org: "o1",
126
+ workspaceEntries: [
127
+ {
128
+ name: "my-repo",
129
+ source: {
130
+ gitRepo: {
131
+ url: "https://github.com/example/repo.git",
132
+ branch: "main",
133
+ },
134
+ },
135
+ },
136
+ ],
137
+ });
138
+
139
+ const proto = captured[0].message as Session;
140
+ const entries = proto.spec?.workspaceEntries;
141
+ expect(entries).toHaveLength(1);
142
+ expect(entries![0].name).toBe("my-repo");
143
+
144
+ const source = entries![0].source;
145
+ expect(source?.source?.case).toBe("gitRepo");
146
+ if (source?.source?.case === "gitRepo") {
147
+ expect(source.source.value.url).toBe(
148
+ "https://github.com/example/repo.git",
149
+ );
150
+ expect(source.source.value.branch).toBe("main");
151
+ }
152
+ });
153
+
154
+ it("serializes workspace entries with local path source", async () => {
155
+ await client.create({
156
+ name: "s1",
157
+ org: "o1",
158
+ workspaceEntries: [
159
+ {
160
+ name: "local",
161
+ source: {
162
+ localPath: { path: "/home/user/project" },
163
+ },
164
+ },
165
+ ],
166
+ });
167
+
168
+ const proto = captured[0].message as Session;
169
+ const entries = proto.spec?.workspaceEntries;
170
+ expect(entries).toHaveLength(1);
171
+
172
+ const source = entries![0].source;
173
+ expect(source?.source?.case).toBe("localPath");
174
+ if (source?.source?.case === "localPath") {
175
+ expect(source.source.value.path).toBe("/home/user/project");
176
+ }
177
+ });
178
+
179
+ it("routes create through the command controller", async () => {
180
+ await client.create({ name: "s1", org: "o1" });
181
+ expect(captured[0].methodName).toBe("create");
182
+ });
183
+
184
+ it("routes apply through the command controller", async () => {
185
+ await client.apply({ name: "s1", org: "o1" });
186
+ expect(captured[0].methodName).toBe("apply");
187
+ });
188
+
189
+ it("routes get through the query controller with SessionId", async () => {
190
+ await client.get("session-id-123");
191
+ const message = captured[0].message as { value: string };
192
+ expect(captured[0].methodName).toBe("get");
193
+ expect(message.value).toBe("session-id-123");
194
+ });
195
+
196
+ it("routes delete through the command controller with SessionId", async () => {
197
+ await client.delete("session-id-456");
198
+ const message = captured[0].message as { value: string };
199
+ expect(captured[0].methodName).toBe("delete");
200
+ expect(message.value).toBe("session-id-456");
201
+ });
202
+ });
package/src/gen/agent.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  // Code generated by stigmer-codegen. DO NOT EDIT.
2
2
 
3
3
  import { wrapError } from "./errors";
4
+ import { stripUndefined } from "./proto-utils";
4
5
  import { type ListParams, type ListResult, type EnvSpecInput, type ResourceRef } from "./types";
5
6
  import { create } from "@bufbuild/protobuf";
6
7
  import { createClient, type Client, type Transport } from "@connectrpc/connect";
7
8
  import { AgentSchema, type Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
8
9
  import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
9
- import { AgentIdSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/io_pb";
10
+ import { AgentIdSchema, GetDefaultAgentRequestSchema, type GetDefaultAgentRequest } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/io_pb";
10
11
  import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
11
- import { AgentSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
12
+ import { AgentSpecSchema, ToolApprovalOverrideSchema, McpServerUsageSchema, McpAccessSchema, SubAgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
13
+ import { EnvironmentSpecSchema, EnvironmentValueSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
12
14
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
13
15
  import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
14
16
  import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
@@ -64,6 +66,12 @@ export class AgentClient {
64
66
  } catch (e) { throw wrapError(e); }
65
67
  }
66
68
 
69
+ async getDefault(input: GetDefaultAgentRequest): Promise<Agent> {
70
+ try {
71
+ return await this.query.getDefault(input);
72
+ } catch (e) { throw wrapError(e); }
73
+ }
74
+
67
75
  async list(params: ListParams): Promise<ListResult> {
68
76
  try {
69
77
  const resp = await this.search.search(create(SearchRequestSchema, {
@@ -85,7 +93,9 @@ export class AgentClient {
85
93
  /** Input for creating/updating a Agent. */
86
94
  export interface AgentInput {
87
95
  name: string;
96
+ slug?: string;
88
97
  org: string;
98
+ labels?: Record<string, string>;
89
99
  description?: string;
90
100
  iconUrl?: string;
91
101
  instructions?: string;
@@ -125,22 +135,69 @@ export interface McpAccessInput {
125
135
  enabledTools?: string[];
126
136
  }
127
137
 
138
+ function buildToolApprovalOverrideProto(input: ToolApprovalOverrideInput) {
139
+ return Object.assign(create(ToolApprovalOverrideSchema), stripUndefined({
140
+ toolName: input.toolName,
141
+ requiresApproval: input.requiresApproval,
142
+ message: input.message,
143
+ }));
144
+ }
145
+
146
+ function buildMcpServerUsageProto(input: McpServerUsageInput) {
147
+ const msg = create(McpServerUsageSchema);
148
+ if (input.mcpServerRef) msg.mcpServerRef = create(ApiResourceReferenceSchema, input.mcpServerRef);
149
+ if (input.enabledTools) msg.enabledTools = input.enabledTools;
150
+ if (input.toolApprovalOverrides) msg.toolApprovalOverrides = input.toolApprovalOverrides.map(buildToolApprovalOverrideProto);
151
+ return msg;
152
+ }
153
+
154
+ function buildMcpAccessProto(input: McpAccessInput) {
155
+ return Object.assign(create(McpAccessSchema), stripUndefined({
156
+ mcpServer: input.mcpServer,
157
+ enabledTools: input.enabledTools,
158
+ }));
159
+ }
160
+
161
+ function buildSubAgentProto(input: SubAgentInput) {
162
+ const msg = create(SubAgentSchema);
163
+ if (input.name !== undefined) msg.name = input.name;
164
+ if (input.description !== undefined) msg.description = input.description;
165
+ if (input.instructions !== undefined) msg.instructions = input.instructions;
166
+ if (input.mcpAccess) msg.mcpAccess = input.mcpAccess.map(buildMcpAccessProto);
167
+ if (input.skillRefs) msg.skillRefs = input.skillRefs.map(r => create(ApiResourceReferenceSchema, r));
168
+ if (input.modelOverride !== undefined) msg.modelOverride = input.modelOverride;
169
+ return msg;
170
+ }
171
+
128
172
  function buildAgentProto(input: AgentInput): Agent {
173
+ const mcpServerUsages = input.mcpServerUsages?.map(buildMcpServerUsageProto);
174
+ const skillRefs = input.skillRefs?.map(r => create(ApiResourceReferenceSchema, r));
175
+ const subAgents = input.subAgents?.map(buildSubAgentProto);
176
+ let envSpec;
177
+ if (input.envSpec) {
178
+ const es = create(EnvironmentSpecSchema);
179
+ for (const [k, v] of Object.entries(input.envSpec.variables)) {
180
+ es.data[k] = create(EnvironmentValueSchema, { value: v.value, isSecret: v.isSecret, description: v.description });
181
+ }
182
+ envSpec = es;
183
+ }
129
184
  return Object.assign(create(AgentSchema), {
130
185
  apiVersion: "agentic.stigmer.ai/v1",
131
186
  kind: "Agent",
132
187
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
133
188
  name: input.name,
134
189
  org: input.org,
190
+ ...(input.slug && { slug: input.slug }),
191
+ ...(input.labels && { labels: input.labels }),
135
192
  }),
136
- spec: Object.assign(create(AgentSpecSchema), {
193
+ spec: Object.assign(create(AgentSpecSchema), stripUndefined({
137
194
  description: input.description,
138
195
  iconUrl: input.iconUrl,
139
196
  instructions: input.instructions,
140
- mcpServerUsages: input.mcpServerUsages,
141
- skillRefs: input.skillRefs,
142
- subAgents: input.subAgents,
143
- envSpec: input.envSpec,
144
- }),
197
+ mcpServerUsages,
198
+ skillRefs,
199
+ subAgents,
200
+ envSpec,
201
+ })),
145
202
  }) as Agent;
146
203
  }
@@ -1,14 +1,16 @@
1
1
  // Code generated by stigmer-codegen. DO NOT EDIT.
2
2
 
3
3
  import { wrapError } from "./errors";
4
+ import { stripUndefined } from "./proto-utils";
4
5
  import { type EnvVarInput } from "./types";
5
6
  import { create } from "@bufbuild/protobuf";
6
7
  import { createClient, type Client, type Transport } from "@connectrpc/connect";
7
8
  import { AgentExecutionSchema, type AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
8
9
  import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/command_pb";
9
- import { AgentExecutionIdSchema, AgentExecutionUpdateStatusInputSchema, SubmitApprovalInputSchema, CancelAgentExecutionInputSchema, TerminateAgentExecutionInputSchema, RecoverAgentExecutionInputSchema, PauseAgentExecutionInputSchema, ResumeAgentExecutionInputSchema, UploadAttachmentRequestSchema, UploadAttachmentResponseSchema, ListAgentExecutionsRequestSchema, AgentExecutionListSchema, ListAgentExecutionsBySessionRequestSchema, GetArtifactDownloadUrlRequestSchema, GetArtifactDownloadUrlResponseSchema, GetSessionUsageReportInputSchema, GetSessionUsageReportOutputSchema, GetAgentUsageReportInputSchema, GetAgentUsageReportOutputSchema, GetOrgUsageReportInputSchema, GetOrgUsageReportOutputSchema, type AgentExecutionUpdateStatusInput, type SubmitApprovalInput, 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 GetSessionUsageReportInput, type GetSessionUsageReportOutput, type GetAgentUsageReportInput, type GetAgentUsageReportOutput, type GetOrgUsageReportInput, type GetOrgUsageReportOutput } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/io_pb";
10
+ import { AgentExecutionIdSchema, AgentExecutionUpdateStatusInputSchema, SubmitApprovalInputSchema, CancelAgentExecutionInputSchema, TerminateAgentExecutionInputSchema, RecoverAgentExecutionInputSchema, PauseAgentExecutionInputSchema, ResumeAgentExecutionInputSchema, UploadAttachmentRequestSchema, UploadAttachmentResponseSchema, ListAgentExecutionsRequestSchema, AgentExecutionListSchema, ListAgentExecutionsBySessionRequestSchema, GetArtifactDownloadUrlRequestSchema, GetArtifactDownloadUrlResponseSchema, GetArtifactContentRequestSchema, GetArtifactContentResponseSchema, GetSessionUsageReportInputSchema, GetSessionUsageReportOutputSchema, GetAgentUsageReportInputSchema, GetAgentUsageReportOutputSchema, GetOrgUsageReportInputSchema, GetOrgUsageReportOutputSchema, type AgentExecutionUpdateStatusInput, type SubmitApprovalInput, 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 GetSessionUsageReportInput, type GetSessionUsageReportOutput, type GetAgentUsageReportInput, type GetAgentUsageReportOutput, type GetOrgUsageReportInput, type GetOrgUsageReportOutput } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/io_pb";
10
11
  import { AgentExecutionQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/query_pb";
11
- import { AgentExecutionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
12
+ import { AgentExecutionSpecSchema, ContextManagementConfigSchema, ExecutionConfigSchema, AttachmentSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
13
+ import { ExecutionValueSchema } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
12
14
  import { ApiResourceIdSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
13
15
  import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
14
16
 
@@ -120,6 +122,12 @@ export class AgentExecutionClient {
120
122
  } catch (e) { throw wrapError(e); }
121
123
  }
122
124
 
125
+ async getArtifactContent(input: GetArtifactContentRequest): Promise<GetArtifactContentResponse> {
126
+ try {
127
+ return await this.query.getArtifactContent(input);
128
+ } catch (e) { throw wrapError(e); }
129
+ }
130
+
123
131
  async getSessionUsageReport(input: GetSessionUsageReportInput): Promise<GetSessionUsageReportOutput> {
124
132
  try {
125
133
  return await this.query.getSessionUsageReport(input);
@@ -142,7 +150,9 @@ export class AgentExecutionClient {
142
150
  /** Input for creating/updating a AgentExecution. */
143
151
  export interface AgentExecutionInput {
144
152
  name: string;
153
+ slug?: string;
145
154
  org: string;
155
+ labels?: Record<string, string>;
146
156
  sessionId?: string;
147
157
  agentId?: string;
148
158
  message?: string;
@@ -181,25 +191,63 @@ export interface AttachmentInput {
181
191
  localPath?: string;
182
192
  }
183
193
 
194
+ function buildContextManagementConfigProto(input: ContextManagementConfigInput) {
195
+ return Object.assign(create(ContextManagementConfigSchema), stripUndefined({
196
+ disableSummarization: input.disableSummarization,
197
+ customTriggerThreshold: input.customTriggerThreshold,
198
+ customTargetTokens: input.customTargetTokens,
199
+ }));
200
+ }
201
+
202
+ function buildExecutionConfigProto(input: ExecutionConfigInput) {
203
+ const msg = create(ExecutionConfigSchema);
204
+ if (input.modelName !== undefined) msg.modelName = input.modelName;
205
+ if (input.contextManagement) msg.contextManagement = buildContextManagementConfigProto(input.contextManagement);
206
+ if (input.maxToolRounds !== undefined) msg.maxToolRounds = input.maxToolRounds;
207
+ if (input.maxToolResultChars !== undefined) msg.maxToolResultChars = input.maxToolResultChars;
208
+ if (input.maxCostUsd !== undefined) msg.maxCostUsd = input.maxCostUsd;
209
+ return msg;
210
+ }
211
+
212
+ function buildAttachmentProto(input: AttachmentInput) {
213
+ return Object.assign(create(AttachmentSchema), stripUndefined({
214
+ filename: input.filename,
215
+ storageKey: input.storageKey,
216
+ mountPath: input.mountPath,
217
+ contentType: input.contentType,
218
+ extract: input.extract,
219
+ localPath: input.localPath,
220
+ }));
221
+ }
222
+
184
223
  function buildAgentExecutionProto(input: AgentExecutionInput): AgentExecution {
224
+ const executionConfig = input.executionConfig ? buildExecutionConfigProto(input.executionConfig) : undefined;
225
+ let runtimeEnv;
226
+ if (input.runtimeEnv) {
227
+ runtimeEnv = Object.fromEntries(Object.entries(input.runtimeEnv).map(([k, v]) =>
228
+ [k, create(ExecutionValueSchema, { value: v.value, isSecret: v.isSecret })]));
229
+ }
230
+ const attachments = input.attachments?.map(buildAttachmentProto);
185
231
  return Object.assign(create(AgentExecutionSchema), {
186
232
  apiVersion: "agentic.stigmer.ai/v1",
187
233
  kind: "AgentExecution",
188
234
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
189
235
  name: input.name,
190
236
  org: input.org,
237
+ ...(input.slug && { slug: input.slug }),
238
+ ...(input.labels && { labels: input.labels }),
191
239
  }),
192
- spec: Object.assign(create(AgentExecutionSpecSchema), {
240
+ spec: Object.assign(create(AgentExecutionSpecSchema), stripUndefined({
193
241
  sessionId: input.sessionId,
194
242
  agentId: input.agentId,
195
243
  message: input.message,
196
- executionConfig: input.executionConfig,
197
- runtimeEnv: input.runtimeEnv,
244
+ executionConfig,
245
+ runtimeEnv,
198
246
  callbackToken: input.callbackToken,
199
247
  autoApproveAll: input.autoApproveAll,
200
248
  parentWorkflowId: input.parentWorkflowId,
201
- attachments: input.attachments,
249
+ attachments,
202
250
  workspaceFileRefs: input.workspaceFileRefs,
203
- }),
251
+ })),
204
252
  }) as AgentExecution;
205
253
  }
@@ -1,12 +1,13 @@
1
1
  // Code generated by stigmer-codegen. DO NOT EDIT.
2
2
 
3
3
  import { wrapError } from "./errors";
4
+ import { stripUndefined } from "./proto-utils";
4
5
  import { type ResourceRef } from "./types";
5
6
  import { create } from "@bufbuild/protobuf";
6
7
  import { createClient, type Client, type Transport } from "@connectrpc/connect";
7
8
  import { AgentInstanceSchema, type AgentInstance } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/api_pb";
8
9
  import { AgentInstanceCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/command_pb";
9
- import { AgentInstanceIdSchema, GetAgentInstancesByAgentRequestSchema, AgentInstanceListSchema, type GetAgentInstancesByAgentRequest, type AgentInstanceList } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/io_pb";
10
+ import { AgentInstanceIdSchema, GetAgentInstancesByAgentRequestSchema, AgentInstanceListSchema, ListAgentInstancesRequestSchema, type GetAgentInstancesByAgentRequest, type AgentInstanceList, type ListAgentInstancesRequest } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/io_pb";
10
11
  import { AgentInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/query_pb";
11
12
  import { AgentInstanceSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/spec_pb";
12
13
  import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
@@ -63,29 +64,40 @@ export class AgentInstanceClient {
63
64
  return await this.query.getByReference(create(ApiResourceReferenceSchema, ref));
64
65
  } catch (e) { throw wrapError(e); }
65
66
  }
67
+
68
+ async list(input: ListAgentInstancesRequest): Promise<AgentInstanceList> {
69
+ try {
70
+ return await this.query.list(input);
71
+ } catch (e) { throw wrapError(e); }
72
+ }
66
73
  }
67
74
 
68
75
  /** Input for creating/updating a AgentInstance. */
69
76
  export interface AgentInstanceInput {
70
77
  name: string;
78
+ slug?: string;
71
79
  org: string;
80
+ labels?: Record<string, string>;
72
81
  agentId?: string;
73
82
  description?: string;
74
83
  environmentRefs?: ResourceRef[];
75
84
  }
76
85
 
77
86
  function buildAgentInstanceProto(input: AgentInstanceInput): AgentInstance {
87
+ const environmentRefs = input.environmentRefs?.map(r => create(ApiResourceReferenceSchema, r));
78
88
  return Object.assign(create(AgentInstanceSchema), {
79
89
  apiVersion: "agentic.stigmer.ai/v1",
80
90
  kind: "AgentInstance",
81
91
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
82
92
  name: input.name,
83
93
  org: input.org,
94
+ ...(input.slug && { slug: input.slug }),
95
+ ...(input.labels && { labels: input.labels }),
84
96
  }),
85
- spec: Object.assign(create(AgentInstanceSpecSchema), {
97
+ spec: Object.assign(create(AgentInstanceSpecSchema), stripUndefined({
86
98
  agentId: input.agentId,
87
99
  description: input.description,
88
- environmentRefs: input.environmentRefs,
89
- }),
100
+ environmentRefs,
101
+ })),
90
102
  }) as AgentInstance;
91
103
  }
package/src/gen/apikey.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // Code generated by stigmer-codegen. DO NOT EDIT.
2
2
 
3
3
  import { wrapError } from "./errors";
4
+ import { stripUndefined } from "./proto-utils";
4
5
  import { create } from "@bufbuild/protobuf";
5
6
  import { EmptySchema } from "@bufbuild/protobuf/wkt";
6
7
  import { createClient, type Client, type Transport } from "@connectrpc/connect";
@@ -61,7 +62,9 @@ export class ApiKeyClient {
61
62
  /** Input for creating/updating a ApiKey. */
62
63
  export interface ApiKeyInput {
63
64
  name: string;
65
+ slug?: string;
64
66
  org: string;
67
+ labels?: Record<string, string>;
65
68
  keyHash?: string;
66
69
  fingerprint?: string;
67
70
  expiresAt?: Date | string;
@@ -75,12 +78,14 @@ function buildApiKeyProto(input: ApiKeyInput): ApiKey {
75
78
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
76
79
  name: input.name,
77
80
  org: input.org,
81
+ ...(input.slug && { slug: input.slug }),
82
+ ...(input.labels && { labels: input.labels }),
78
83
  }),
79
- spec: Object.assign(create(ApiKeySpecSchema), {
84
+ spec: Object.assign(create(ApiKeySpecSchema), stripUndefined({
80
85
  keyHash: input.keyHash,
81
86
  fingerprint: input.fingerprint,
82
87
  expiresAt: input.expiresAt,
83
88
  neverExpires: input.neverExpires,
84
- }),
89
+ })),
85
90
  }) as ApiKey;
86
91
  }
@@ -1,13 +1,15 @@
1
1
  // Code generated by stigmer-codegen. DO NOT EDIT.
2
2
 
3
3
  import { wrapError } from "./errors";
4
+ import { stripUndefined } from "./proto-utils";
4
5
  import { type DeleteResourceInput, type ResourceRef, type EnvVarInput } from "./types";
5
6
  import { create } from "@bufbuild/protobuf";
6
7
  import { createClient, type Client, type Transport } from "@connectrpc/connect";
7
8
  import { EnvironmentSchema, type Environment } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/api_pb";
8
9
  import { EnvironmentCommandController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/command_pb";
10
+ import { UpdateEnvironmentVariablesRequestSchema, RemoveEnvironmentVariablesRequestSchema, EnvironmentSecretValueInputSchema, ListEnvironmentsRequestSchema, EnvironmentListSchema, type UpdateEnvironmentVariablesRequest, type RemoveEnvironmentVariablesRequest, type EnvironmentSecretValueInput, type ListEnvironmentsRequest, type EnvironmentList } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/io_pb";
9
11
  import { EnvironmentQueryController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/query_pb";
10
- import { EnvironmentSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
12
+ import { EnvironmentValueSchema, EnvironmentSpecSchema, type EnvironmentValue } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
11
13
  import { ApiResourceIdSchema, ApiResourceReferenceSchema, ApiResourceDeleteInputSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
12
14
  import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
13
15
 
@@ -49,6 +51,18 @@ export class EnvironmentClient {
49
51
  } catch (e) { throw wrapError(e); }
50
52
  }
51
53
 
54
+ async updateVariables(input: UpdateEnvironmentVariablesRequest): Promise<Environment> {
55
+ try {
56
+ return await this.command.updateVariables(input);
57
+ } catch (e) { throw wrapError(e); }
58
+ }
59
+
60
+ async removeVariables(input: RemoveEnvironmentVariablesRequest): Promise<Environment> {
61
+ try {
62
+ return await this.command.removeVariables(input);
63
+ } catch (e) { throw wrapError(e); }
64
+ }
65
+
52
66
  async get(id: string): Promise<Environment> {
53
67
  try {
54
68
  return await this.query.get(create(ApiResourceIdSchema, { value: id }));
@@ -60,27 +74,48 @@ export class EnvironmentClient {
60
74
  return await this.query.getByReference(create(ApiResourceReferenceSchema, ref));
61
75
  } catch (e) { throw wrapError(e); }
62
76
  }
77
+
78
+ async getSecretValue(input: EnvironmentSecretValueInput): Promise<EnvironmentValue> {
79
+ try {
80
+ return await this.query.getSecretValue(input);
81
+ } catch (e) { throw wrapError(e); }
82
+ }
83
+
84
+ async list(input: ListEnvironmentsRequest): Promise<EnvironmentList> {
85
+ try {
86
+ return await this.query.list(input);
87
+ } catch (e) { throw wrapError(e); }
88
+ }
63
89
  }
64
90
 
65
91
  /** Input for creating/updating a Environment. */
66
92
  export interface EnvironmentInput {
67
93
  name: string;
94
+ slug?: string;
68
95
  org: string;
96
+ labels?: Record<string, string>;
69
97
  description?: string;
70
98
  data?: Record<string, EnvVarInput>;
71
99
  }
72
100
 
73
101
  function buildEnvironmentProto(input: EnvironmentInput): Environment {
102
+ let data;
103
+ if (input.data) {
104
+ data = Object.fromEntries(Object.entries(input.data).map(([k, v]) =>
105
+ [k, create(EnvironmentValueSchema, { value: v.value, isSecret: v.isSecret, description: v.description })]));
106
+ }
74
107
  return Object.assign(create(EnvironmentSchema), {
75
108
  apiVersion: "agentic.stigmer.ai/v1",
76
109
  kind: "Environment",
77
110
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
78
111
  name: input.name,
79
112
  org: input.org,
113
+ ...(input.slug && { slug: input.slug }),
114
+ ...(input.labels && { labels: input.labels }),
80
115
  }),
81
- spec: Object.assign(create(EnvironmentSpecSchema), {
116
+ spec: Object.assign(create(EnvironmentSpecSchema), stripUndefined({
82
117
  description: input.description,
83
- data: input.data,
84
- }),
118
+ data,
119
+ })),
85
120
  }) as Environment;
86
121
  }
@@ -1,6 +1,7 @@
1
1
  // Code generated by stigmer-codegen. DO NOT EDIT.
2
2
 
3
3
  import { wrapError } from "./errors";
4
+ import { stripUndefined } from "./proto-utils";
4
5
  import { type DeleteResourceInput, type ResourceRef, type EnvVarInput } from "./types";
5
6
  import { create } from "@bufbuild/protobuf";
6
7
  import { createClient, type Client, type Transport } from "@connectrpc/connect";
@@ -8,7 +9,7 @@ import { ExecutionContextSchema, type ExecutionContext } from "@stigmer/protos/a
8
9
  import { ExecutionContextCommandController } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/command_pb";
9
10
  import { ExecutionContextIdSchema, ExecutionContextExecutionIdInputSchema, type ExecutionContextExecutionIdInput } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/io_pb";
10
11
  import { ExecutionContextQueryController } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/query_pb";
11
- import { ExecutionContextSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
12
+ import { ExecutionContextSpecSchema, ExecutionValueSchema } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
12
13
  import { ApiResourceReferenceSchema, ApiResourceDeleteInputSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
13
14
  import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
14
15
 
@@ -66,22 +67,31 @@ export class ExecutionContextClient {
66
67
  /** Input for creating/updating a ExecutionContext. */
67
68
  export interface ExecutionContextInput {
68
69
  name: string;
70
+ slug?: string;
69
71
  org: string;
72
+ labels?: Record<string, string>;
70
73
  executionId?: string;
71
74
  data?: Record<string, EnvVarInput>;
72
75
  }
73
76
 
74
77
  function buildExecutionContextProto(input: ExecutionContextInput): ExecutionContext {
78
+ let data;
79
+ if (input.data) {
80
+ data = Object.fromEntries(Object.entries(input.data).map(([k, v]) =>
81
+ [k, create(ExecutionValueSchema, { value: v.value, isSecret: v.isSecret })]));
82
+ }
75
83
  return Object.assign(create(ExecutionContextSchema), {
76
84
  apiVersion: "agentic.stigmer.ai/v1",
77
85
  kind: "ExecutionContext",
78
86
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
79
87
  name: input.name,
80
88
  org: input.org,
89
+ ...(input.slug && { slug: input.slug }),
90
+ ...(input.labels && { labels: input.labels }),
81
91
  }),
82
- spec: Object.assign(create(ExecutionContextSpecSchema), {
92
+ spec: Object.assign(create(ExecutionContextSpecSchema), stripUndefined({
83
93
  executionId: input.executionId,
84
- data: input.data,
85
- }),
94
+ data,
95
+ })),
86
96
  }) as ExecutionContext;
87
97
  }