@stigmer/sdk 3.12.4 → 3.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/mcpserver-connect.test.d.ts +2 -0
- package/__tests__/mcpserver-connect.test.d.ts.map +1 -0
- package/__tests__/mcpserver-connect.test.js +146 -0
- package/__tests__/mcpserver-connect.test.js.map +1 -0
- package/__tests__/update-input-roundtrip.test.d.ts +2 -0
- package/__tests__/update-input-roundtrip.test.d.ts.map +1 -0
- package/__tests__/update-input-roundtrip.test.js +791 -0
- package/__tests__/update-input-roundtrip.test.js.map +1 -0
- package/__tests__/update-input.test.d.ts +2 -0
- package/__tests__/update-input.test.d.ts.map +1 -0
- package/__tests__/update-input.test.js +188 -0
- package/__tests__/update-input.test.js.map +1 -0
- package/gen/agent.d.ts +21 -0
- package/gen/agent.d.ts.map +1 -1
- package/gen/agent.js +73 -1
- package/gen/agent.js.map +1 -1
- package/gen/agentchannel.d.ts +23 -1
- package/gen/agentchannel.d.ts.map +1 -1
- package/gen/agentchannel.js +55 -1
- package/gen/agentchannel.js.map +1 -1
- package/gen/agentexecution.d.ts +29 -1
- package/gen/agentexecution.d.ts.map +1 -1
- package/gen/agentexecution.js +155 -2
- package/gen/agentexecution.js.map +1 -1
- package/gen/agentinstance.d.ts +21 -0
- package/gen/agentinstance.d.ts.map +1 -1
- package/gen/agentinstance.js +32 -1
- package/gen/agentinstance.js.map +1 -1
- package/gen/agentshare.d.ts +23 -1
- package/gen/agentshare.d.ts.map +1 -1
- package/gen/agentshare.js +53 -1
- package/gen/agentshare.js.map +1 -1
- package/gen/apikey.d.ts +21 -0
- package/gen/apikey.d.ts.map +1 -1
- package/gen/apikey.js +33 -1
- package/gen/apikey.js.map +1 -1
- package/gen/artifact.d.ts +8 -0
- package/gen/artifact.d.ts.map +1 -1
- package/gen/artifact.js +1 -0
- package/gen/artifact.js.map +1 -1
- package/gen/channelapp.d.ts +21 -0
- package/gen/channelapp.d.ts.map +1 -1
- package/gen/channelapp.js +45 -0
- package/gen/channelapp.js.map +1 -1
- package/gen/client.d.ts +3 -3
- package/gen/client.d.ts.map +1 -1
- package/gen/environment.d.ts +21 -0
- package/gen/environment.d.ts.map +1 -1
- package/gen/environment.js +31 -1
- package/gen/environment.js.map +1 -1
- package/gen/executioncontext.d.ts +8 -0
- package/gen/executioncontext.d.ts.map +1 -1
- package/gen/executioncontext.js +1 -0
- package/gen/executioncontext.js.map +1 -1
- package/gen/iampolicy.d.ts +8 -0
- package/gen/iampolicy.d.ts.map +1 -1
- package/gen/iampolicy.js +1 -0
- package/gen/iampolicy.js.map +1 -1
- package/gen/identityaccount.d.ts +29 -0
- package/gen/identityaccount.d.ts.map +1 -1
- package/gen/identityaccount.js +57 -2
- package/gen/identityaccount.js.map +1 -1
- package/gen/identityprovider.d.ts +21 -0
- package/gen/identityprovider.d.ts.map +1 -1
- package/gen/identityprovider.js +40 -0
- package/gen/identityprovider.js.map +1 -1
- package/gen/invitation.d.ts +8 -0
- package/gen/invitation.d.ts.map +1 -1
- package/gen/invitation.js +1 -0
- package/gen/invitation.js.map +1 -1
- package/gen/mcpserver.d.ts +22 -0
- package/gen/mcpserver.d.ts.map +1 -1
- package/gen/mcpserver.js +87 -1
- package/gen/mcpserver.js.map +1 -1
- package/gen/oauthapp.d.ts +23 -1
- package/gen/oauthapp.d.ts.map +1 -1
- package/gen/oauthapp.js +40 -0
- package/gen/oauthapp.js.map +1 -1
- package/gen/organization.d.ts +26 -0
- package/gen/organization.d.ts.map +1 -1
- package/gen/organization.js +49 -2
- package/gen/organization.js.map +1 -1
- package/gen/platformclient.d.ts +22 -0
- package/gen/platformclient.d.ts.map +1 -1
- package/gen/platformclient.js +42 -1
- package/gen/platformclient.js.map +1 -1
- package/gen/project.d.ts +21 -0
- package/gen/project.d.ts.map +1 -1
- package/gen/project.js +32 -1
- package/gen/project.js.map +1 -1
- package/gen/proto-utils.d.ts +36 -0
- package/gen/proto-utils.d.ts.map +1 -1
- package/gen/proto-utils.js +58 -0
- package/gen/proto-utils.js.map +1 -1
- package/gen/schedule.d.ts +23 -1
- package/gen/schedule.d.ts.map +1 -1
- package/gen/schedule.js +79 -1
- package/gen/schedule.js.map +1 -1
- package/gen/session.d.ts +21 -0
- package/gen/session.d.ts.map +1 -1
- package/gen/session.js +80 -1
- package/gen/session.js.map +1 -1
- package/gen/skill.d.ts +8 -0
- package/gen/skill.d.ts.map +1 -1
- package/gen/skill.js +1 -0
- package/gen/skill.js.map +1 -1
- package/gen/workflow.d.ts +21 -0
- package/gen/workflow.d.ts.map +1 -1
- package/gen/workflow.js +79 -0
- package/gen/workflow.js.map +1 -1
- package/gen/workflowexecution.d.ts +21 -0
- package/gen/workflowexecution.d.ts.map +1 -1
- package/gen/workflowexecution.js +36 -1
- package/gen/workflowexecution.js.map +1 -1
- package/gen/workflowinstance.d.ts +21 -0
- package/gen/workflowinstance.d.ts.map +1 -1
- package/gen/workflowinstance.js +33 -1
- package/gen/workflowinstance.js.map +1 -1
- package/index.d.ts +21 -20
- package/index.d.ts.map +1 -1
- package/index.js +25 -21
- package/index.js.map +1 -1
- package/mcpserver-connect.d.ts +79 -0
- package/mcpserver-connect.d.ts.map +1 -0
- package/mcpserver-connect.js +114 -0
- package/mcpserver-connect.js.map +1 -0
- package/package.json +2 -2
- package/src/__tests__/mcpserver-connect.test.ts +181 -0
- package/src/__tests__/update-input-roundtrip.test.ts +1031 -0
- package/src/__tests__/update-input.test.ts +250 -0
- package/src/gen/agent.ts +89 -3
- package/src/gen/agentchannel.ts +72 -4
- package/src/gen/agentexecution.ts +188 -6
- package/src/gen/agentinstance.ts +41 -1
- package/src/gen/agentshare.ts +68 -4
- package/src/gen/apikey.ts +42 -1
- package/src/gen/artifact.ts +9 -0
- package/src/gen/channelapp.ts +57 -1
- package/src/gen/client.ts +3 -3
- package/src/gen/environment.ts +40 -1
- package/src/gen/executioncontext.ts +9 -0
- package/src/gen/iampolicy.ts +9 -0
- package/src/gen/identityaccount.ts +77 -2
- package/src/gen/identityprovider.ts +49 -0
- package/src/gen/invitation.ts +9 -0
- package/src/gen/mcpserver.ts +101 -3
- package/src/gen/oauthapp.ts +51 -1
- package/src/gen/organization.ts +66 -2
- package/src/gen/platformclient.ts +52 -1
- package/src/gen/project.ts +41 -1
- package/src/gen/proto-utils.ts +64 -0
- package/src/gen/schedule.ts +98 -4
- package/src/gen/session.ts +97 -3
- package/src/gen/skill.ts +9 -0
- package/src/gen/workflow.ts +96 -2
- package/src/gen/workflowexecution.ts +45 -1
- package/src/gen/workflowinstance.ts +42 -1
- package/src/index.ts +32 -3
- package/src/mcpserver-connect.ts +159 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined, toTimestamp } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toTimestamp, toResourceRefInputs } from "./proto-utils.js";
|
|
5
5
|
import { type DeleteResourceInput, type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
|
+
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
|
7
8
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
9
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
9
10
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
@@ -90,6 +91,14 @@ export class PlatformClientClient {
|
|
|
90
91
|
|
|
91
92
|
/** Input for creating/updating a PlatformClient. */
|
|
92
93
|
export interface PlatformClientInput {
|
|
94
|
+
/**
|
|
95
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
96
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
97
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
98
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
99
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
100
|
+
*/
|
|
101
|
+
id?: string;
|
|
93
102
|
name: string;
|
|
94
103
|
slug?: string;
|
|
95
104
|
org: string;
|
|
@@ -104,14 +113,17 @@ export interface PlatformClientInput {
|
|
|
104
113
|
autoGrantOnOrg?: boolean;
|
|
105
114
|
autoGrantRole?: IamRole;
|
|
106
115
|
allowedOrigins?: string[];
|
|
116
|
+
environmentRefs?: ResourceRef[];
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
export function buildPlatformClientProto(input: PlatformClientInput): PlatformClient {
|
|
110
120
|
const expiresAt = input.expiresAt !== undefined ? toTimestamp(input.expiresAt) : undefined;
|
|
121
|
+
const environmentRefs = input.environmentRefs?.map(r => create(ApiResourceReferenceSchema, { ...r, kind: 53 }));
|
|
111
122
|
return Object.assign(create(PlatformClientSchema), {
|
|
112
123
|
apiVersion: "iam.stigmer.ai/v1",
|
|
113
124
|
kind: "PlatformClient",
|
|
114
125
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
126
|
+
...(input.id && { id: input.id }),
|
|
115
127
|
name: input.name,
|
|
116
128
|
org: input.org,
|
|
117
129
|
...(input.slug && { slug: input.slug }),
|
|
@@ -128,6 +140,45 @@ export function buildPlatformClientProto(input: PlatformClientInput): PlatformCl
|
|
|
128
140
|
autoGrantOnOrg: input.autoGrantOnOrg,
|
|
129
141
|
autoGrantRole: input.autoGrantRole,
|
|
130
142
|
allowedOrigins: input.allowedOrigins,
|
|
143
|
+
environmentRefs,
|
|
131
144
|
})),
|
|
132
145
|
}) as PlatformClient;
|
|
133
146
|
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Maps a fetched {@link PlatformClient} to a complete {@link PlatformClientInput} for `update()`.
|
|
150
|
+
*
|
|
151
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
152
|
+
* and override only the fields you edit (spread nested objects the same
|
|
153
|
+
* way):
|
|
154
|
+
*
|
|
155
|
+
* await client.update({ ...toPlatformClientUpdateInput(res), description: next });
|
|
156
|
+
*
|
|
157
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
158
|
+
* `version` (pinned refs) and `kind`.
|
|
159
|
+
*/
|
|
160
|
+
export function toPlatformClientUpdateInput(resource: PlatformClient): PlatformClientInput {
|
|
161
|
+
const meta = resource.metadata;
|
|
162
|
+
const spec = resource.spec ?? create(PlatformClientSpecSchema);
|
|
163
|
+
return {
|
|
164
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
165
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
166
|
+
// match, so the id is the ONLY working address.
|
|
167
|
+
id: meta?.id || undefined,
|
|
168
|
+
name: meta?.name ?? "",
|
|
169
|
+
slug: meta?.slug || undefined,
|
|
170
|
+
org: meta?.org ?? "",
|
|
171
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
172
|
+
visibility: meta?.visibility || undefined,
|
|
173
|
+
clientId: spec.clientId || undefined,
|
|
174
|
+
clientSecretHash: spec.clientSecretHash || undefined,
|
|
175
|
+
secretFingerprint: spec.secretFingerprint || undefined,
|
|
176
|
+
expiresAt: spec.expiresAt ? timestampDate(spec.expiresAt) : undefined,
|
|
177
|
+
neverExpires: spec.neverExpires || undefined,
|
|
178
|
+
autoProvisionAccounts: spec.autoProvisionAccounts || undefined,
|
|
179
|
+
autoGrantOnOrg: spec.autoGrantOnOrg || undefined,
|
|
180
|
+
autoGrantRole: spec.autoGrantRole || undefined,
|
|
181
|
+
allowedOrigins: spec.allowedOrigins?.length ? [...spec.allowedOrigins] : undefined,
|
|
182
|
+
environmentRefs: toResourceRefInputs(spec.environmentRefs),
|
|
183
|
+
};
|
|
184
|
+
}
|
package/src/gen/project.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toResourceRefInputs } from "./proto-utils.js";
|
|
5
5
|
import { type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
@@ -64,6 +64,14 @@ export class ProjectClient {
|
|
|
64
64
|
|
|
65
65
|
/** Input for creating/updating a Project. */
|
|
66
66
|
export interface ProjectInput {
|
|
67
|
+
/**
|
|
68
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
69
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
70
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
71
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
72
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
73
|
+
*/
|
|
74
|
+
id?: string;
|
|
67
75
|
name: string;
|
|
68
76
|
slug?: string;
|
|
69
77
|
org: string;
|
|
@@ -80,6 +88,7 @@ export function buildProjectProto(input: ProjectInput): Project {
|
|
|
80
88
|
apiVersion: "tenancy.stigmer.ai/v1",
|
|
81
89
|
kind: "Project",
|
|
82
90
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
91
|
+
...(input.id && { id: input.id }),
|
|
83
92
|
name: input.name,
|
|
84
93
|
org: input.org,
|
|
85
94
|
...(input.slug && { slug: input.slug }),
|
|
@@ -93,3 +102,34 @@ export function buildProjectProto(input: ProjectInput): Project {
|
|
|
93
102
|
})),
|
|
94
103
|
}) as Project;
|
|
95
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Maps a fetched {@link Project} to a complete {@link ProjectInput} for `update()`.
|
|
108
|
+
*
|
|
109
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
110
|
+
* and override only the fields you edit (spread nested objects the same
|
|
111
|
+
* way):
|
|
112
|
+
*
|
|
113
|
+
* await client.update({ ...toProjectUpdateInput(res), description: next });
|
|
114
|
+
*
|
|
115
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
116
|
+
* `version` (pinned refs) and `kind`.
|
|
117
|
+
*/
|
|
118
|
+
export function toProjectUpdateInput(resource: Project): ProjectInput {
|
|
119
|
+
const meta = resource.metadata;
|
|
120
|
+
const spec = resource.spec ?? create(ProjectSpecSchema);
|
|
121
|
+
return {
|
|
122
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
123
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
124
|
+
// match, so the id is the ONLY working address.
|
|
125
|
+
id: meta?.id || undefined,
|
|
126
|
+
name: meta?.name ?? "",
|
|
127
|
+
slug: meta?.slug || undefined,
|
|
128
|
+
org: meta?.org ?? "",
|
|
129
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
130
|
+
visibility: meta?.visibility || undefined,
|
|
131
|
+
entryPoint: spec.entryPoint || undefined,
|
|
132
|
+
description: spec.description || undefined,
|
|
133
|
+
members: toResourceRefInputs(spec.members),
|
|
134
|
+
};
|
|
135
|
+
}
|
package/src/gen/proto-utils.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { timestampFromDate, type Timestamp } from "@bufbuild/protobuf/wkt";
|
|
4
|
+
import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
5
|
+
import type { EnvironmentSpec, EnvironmentValue } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
6
|
+
import type { ExecutionValue } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
|
|
7
|
+
import type { EnvSpecInput, EnvVarInput, ResourceRef } from "./types.js";
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Remove keys whose values are `undefined` so that `Object.assign`
|
|
@@ -24,3 +28,63 @@ export function toTimestamp(value: Date | string): Timestamp {
|
|
|
24
28
|
const date = value instanceof Date ? value : new Date(value);
|
|
25
29
|
return timestampFromDate(date);
|
|
26
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Narrow a fetched ApiResourceReference to the ResourceRef input shape,
|
|
34
|
+
* or `undefined` when the reference is absent/empty (the builders treat a
|
|
35
|
+
* ref without org and slug as "no reference"). `version` is preserved —
|
|
36
|
+
* dropping it would reset a pinned reference to "latest". `kind` is also
|
|
37
|
+
* preserved: builders overwrite it where the proto annotates a reference
|
|
38
|
+
* kind, but refs without that annotation (e.g. an organization's
|
|
39
|
+
* identityProviderRef) carry the stored kind, so dropping it would be
|
|
40
|
+
* lossy.
|
|
41
|
+
*/
|
|
42
|
+
export function toResourceRefInput(ref: ApiResourceReference | undefined): ResourceRef | undefined {
|
|
43
|
+
if (!ref || (!ref.org && !ref.slug)) return undefined;
|
|
44
|
+
return {
|
|
45
|
+
org: ref.org,
|
|
46
|
+
slug: ref.slug,
|
|
47
|
+
...(ref.version && { version: ref.version }),
|
|
48
|
+
...(ref.kind && { kind: ref.kind }),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Map a repeated ApiResourceReference to ResourceRef inputs, or `undefined`
|
|
54
|
+
* when the list is absent/empty (the mappers' canonical shape for empty
|
|
55
|
+
* lists).
|
|
56
|
+
*/
|
|
57
|
+
export function toResourceRefInputs(refs: ApiResourceReference[] | undefined): ResourceRef[] | undefined {
|
|
58
|
+
if (!refs || refs.length === 0) return undefined;
|
|
59
|
+
return refs.map((r) => toResourceRefInput(r) ?? { org: "", slug: "" });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Convert a fetched EnvironmentSpec to the EnvSpecInput shape, or
|
|
64
|
+
* `undefined` when absent/empty.
|
|
65
|
+
*/
|
|
66
|
+
export function toEnvSpecInput(spec: EnvironmentSpec | undefined): EnvSpecInput | undefined {
|
|
67
|
+
if (!spec) return undefined;
|
|
68
|
+
const variables = toEnvVarInputMap(spec.data);
|
|
69
|
+
return variables ? { variables } : undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Convert a map of EnvironmentValue to EnvVarInput entries, or `undefined`
|
|
74
|
+
* when the map is absent/empty.
|
|
75
|
+
*/
|
|
76
|
+
export function toEnvVarInputMap(data: Record<string, EnvironmentValue> | undefined): Record<string, EnvVarInput> | undefined {
|
|
77
|
+
if (!data || Object.keys(data).length === 0) return undefined;
|
|
78
|
+
return Object.fromEntries(Object.entries(data).map(([k, v]) =>
|
|
79
|
+
[k, { value: v.value, isSecret: v.isSecret || undefined, description: v.description || undefined }]));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Convert a map of ExecutionValue to EnvVarInput entries, or `undefined`
|
|
84
|
+
* when the map is absent/empty.
|
|
85
|
+
*/
|
|
86
|
+
export function toExecVarInputMap(data: Record<string, ExecutionValue> | undefined): Record<string, EnvVarInput> | undefined {
|
|
87
|
+
if (!data || Object.keys(data).length === 0) return undefined;
|
|
88
|
+
return Object.fromEntries(Object.entries(data).map(([k, v]) =>
|
|
89
|
+
[k, { value: v.value, isSecret: v.isSecret || undefined }]));
|
|
90
|
+
}
|
package/src/gen/schedule.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toResourceRefInput, toResourceRefInputs } from "./proto-utils.js";
|
|
5
5
|
import { type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
|
-
import { ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
9
|
-
import { RunConfigSchema, AgentInvocationSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/invocation_pb";
|
|
8
|
+
import { ServiceTier, ThinkingMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
9
|
+
import { RunConfigSchema, AgentInvocationSchema, type RunConfig, type AgentInvocation } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/invocation_pb";
|
|
10
10
|
import { ScheduleSchema, type Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
|
|
11
11
|
import { ScheduleCommandController } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/command_pb";
|
|
12
12
|
import { ScheduleIdSchema, ScheduleTriggerResultSchema, GetSchedulesByAgentRequestSchema, ScheduleListSchema, ListSchedulesRequestSchema, ListScheduleRunsRequestSchema, ScheduleRunListSchema, type ScheduleTriggerResult, type GetSchedulesByAgentRequest, type ScheduleList, type ListSchedulesRequest, type ListScheduleRunsRequest, type ScheduleRunList } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/io_pb";
|
|
13
13
|
import { ScheduleQueryController } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/query_pb";
|
|
14
14
|
import { ScheduleSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/spec_pb";
|
|
15
15
|
import { Harness, GitWriteBackMode } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
16
|
-
import { GitRepoSourceSchema, LocalPathSourceSchema, WorkspaceSourceSchema, WorkspaceEntrySchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
|
|
16
|
+
import { GitRepoSourceSchema, LocalPathSourceSchema, WorkspaceSourceSchema, WorkspaceEntrySchema, type GitRepoSource, type LocalPathSource, type WorkspaceSource, type WorkspaceEntry } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
|
|
17
17
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
18
18
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
19
19
|
import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
@@ -98,6 +98,14 @@ export class ScheduleClient {
|
|
|
98
98
|
|
|
99
99
|
/** Input for creating/updating a Schedule. */
|
|
100
100
|
export interface ScheduleInput {
|
|
101
|
+
/**
|
|
102
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
103
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
104
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
105
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
106
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
107
|
+
*/
|
|
108
|
+
id?: string;
|
|
101
109
|
name: string;
|
|
102
110
|
slug?: string;
|
|
103
111
|
org: string;
|
|
@@ -151,6 +159,7 @@ export interface RunConfigInput {
|
|
|
151
159
|
maxCostUsd?: number;
|
|
152
160
|
maxToolRounds?: number;
|
|
153
161
|
serviceTier?: ServiceTier;
|
|
162
|
+
thinkingMode?: ThinkingMode;
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
function buildGitRepoSourceProto(input: GitRepoSourceInput) {
|
|
@@ -192,6 +201,7 @@ function buildRunConfigProto(input: RunConfigInput) {
|
|
|
192
201
|
maxCostUsd: input.maxCostUsd,
|
|
193
202
|
maxToolRounds: input.maxToolRounds,
|
|
194
203
|
serviceTier: input.serviceTier,
|
|
204
|
+
thinkingMode: input.thinkingMode,
|
|
195
205
|
}));
|
|
196
206
|
}
|
|
197
207
|
|
|
@@ -219,6 +229,7 @@ export function buildScheduleProto(input: ScheduleInput): Schedule {
|
|
|
219
229
|
apiVersion: "agentic.stigmer.ai/v1",
|
|
220
230
|
kind: "Schedule",
|
|
221
231
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
232
|
+
...(input.id && { id: input.id }),
|
|
222
233
|
name: input.name,
|
|
223
234
|
org: input.org,
|
|
224
235
|
...(input.slug && { slug: input.slug }),
|
|
@@ -228,3 +239,86 @@ export function buildScheduleProto(input: ScheduleInput): Schedule {
|
|
|
228
239
|
spec,
|
|
229
240
|
}) as Schedule;
|
|
230
241
|
}
|
|
242
|
+
|
|
243
|
+
function toGitRepoSourceInput(msg: GitRepoSource): GitRepoSourceInput {
|
|
244
|
+
return {
|
|
245
|
+
url: msg.url ?? "",
|
|
246
|
+
branch: msg.branch || undefined,
|
|
247
|
+
commit: msg.commit || undefined,
|
|
248
|
+
depth: msg.depth || undefined,
|
|
249
|
+
writeBackMode: msg.writeBackMode || undefined,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function toLocalPathSourceInput(msg: LocalPathSource): LocalPathSourceInput {
|
|
254
|
+
return {
|
|
255
|
+
path: msg.path || undefined,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function toWorkspaceSourceInput(msg: WorkspaceSource): WorkspaceSourceInput {
|
|
260
|
+
return {
|
|
261
|
+
gitRepo: msg.source?.case === "gitRepo" ? toGitRepoSourceInput(msg.source.value) : undefined,
|
|
262
|
+
localPath: msg.source?.case === "localPath" ? toLocalPathSourceInput(msg.source.value) : undefined,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function toWorkspaceEntryInput(msg: WorkspaceEntry): WorkspaceEntryInput {
|
|
267
|
+
return {
|
|
268
|
+
name: msg.name || undefined,
|
|
269
|
+
source: toWorkspaceSourceInput(msg.source ?? create(WorkspaceSourceSchema)),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function toRunConfigInput(msg: RunConfig): RunConfigInput {
|
|
274
|
+
return {
|
|
275
|
+
modelName: msg.modelName || undefined,
|
|
276
|
+
maxCostUsd: msg.maxCostUsd || undefined,
|
|
277
|
+
maxToolRounds: msg.maxToolRounds || undefined,
|
|
278
|
+
serviceTier: msg.serviceTier || undefined,
|
|
279
|
+
thinkingMode: msg.thinkingMode || undefined,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function toAgentInvocationInput(msg: AgentInvocation): AgentInvocationInput {
|
|
284
|
+
return {
|
|
285
|
+
agentRef: toResourceRefInput(msg.agentRef) ?? { org: "", slug: "" },
|
|
286
|
+
message: msg.message || undefined,
|
|
287
|
+
harness: msg.harness || undefined,
|
|
288
|
+
workspaceEntries: msg.workspaceEntries?.length ? msg.workspaceEntries.map(toWorkspaceEntryInput) : undefined,
|
|
289
|
+
environmentRefs: toResourceRefInputs(msg.environmentRefs),
|
|
290
|
+
runConfig: msg.runConfig ? toRunConfigInput(msg.runConfig) : undefined,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Maps a fetched {@link Schedule} to a complete {@link ScheduleInput} for `update()`.
|
|
296
|
+
*
|
|
297
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
298
|
+
* and override only the fields you edit (spread nested objects the same
|
|
299
|
+
* way):
|
|
300
|
+
*
|
|
301
|
+
* await client.update({ ...toScheduleUpdateInput(res), description: next });
|
|
302
|
+
*
|
|
303
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
304
|
+
* `version` (pinned refs) and `kind`.
|
|
305
|
+
*/
|
|
306
|
+
export function toScheduleUpdateInput(resource: Schedule): ScheduleInput {
|
|
307
|
+
const meta = resource.metadata;
|
|
308
|
+
const spec = resource.spec ?? create(ScheduleSpecSchema);
|
|
309
|
+
return {
|
|
310
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
311
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
312
|
+
// match, so the id is the ONLY working address.
|
|
313
|
+
id: meta?.id || undefined,
|
|
314
|
+
name: meta?.name ?? "",
|
|
315
|
+
slug: meta?.slug || undefined,
|
|
316
|
+
org: meta?.org ?? "",
|
|
317
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
318
|
+
visibility: meta?.visibility || undefined,
|
|
319
|
+
cron: spec.cron || undefined,
|
|
320
|
+
timeZone: spec.timeZone || undefined,
|
|
321
|
+
enabled: spec.enabled || undefined,
|
|
322
|
+
agent: spec.target?.case === "agent" ? toAgentInvocationInput(spec.target.value) : undefined,
|
|
323
|
+
};
|
|
324
|
+
}
|
package/src/gen/session.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toResourceRefInput, toResourceRefInputs } from "./proto-utils.js";
|
|
5
5
|
import { type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
|
-
import { ToolApprovalOverrideSchema, McpServerUsageSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
|
|
8
|
+
import { ToolApprovalOverrideSchema, McpServerUsageSchema, type ToolApprovalOverride, type McpServerUsage } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
|
|
9
9
|
import { SessionSchema, type Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
|
|
10
10
|
import { SessionCommandController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/command_pb";
|
|
11
11
|
import { Harness, CursorMode, ExecutionTarget, GitWriteBackMode } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
12
12
|
import { SessionIdSchema, UpdateSessionSubjectRequestSchema, ListSessionsRequestSchema, SessionListSchema, ListSessionsByAgentInstanceRequestSchema, ListSessionsByChannelRequestSchema, type UpdateSessionSubjectRequest, type ListSessionsRequest, type SessionList, type ListSessionsByAgentInstanceRequest, type ListSessionsByChannelRequest } from "@stigmer/protos/ai/stigmer/agentic/session/v1/io_pb";
|
|
13
13
|
import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
|
|
14
14
|
import { SessionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/spec_pb";
|
|
15
|
-
import { GitRepoSourceSchema, LocalPathSourceSchema, WorkspaceSourceSchema, WorkspaceEntrySchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
|
|
15
|
+
import { GitRepoSourceSchema, LocalPathSourceSchema, WorkspaceSourceSchema, WorkspaceEntrySchema, type GitRepoSource, type LocalPathSource, type WorkspaceSource, type WorkspaceEntry } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
|
|
16
16
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
17
17
|
import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
18
18
|
import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
@@ -84,6 +84,14 @@ export class SessionClient {
|
|
|
84
84
|
|
|
85
85
|
/** Input for creating/updating a Session. */
|
|
86
86
|
export interface SessionInput {
|
|
87
|
+
/**
|
|
88
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
89
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
90
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
91
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
92
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
93
|
+
*/
|
|
94
|
+
id?: string;
|
|
87
95
|
name: string;
|
|
88
96
|
slug?: string;
|
|
89
97
|
org: string;
|
|
@@ -199,6 +207,7 @@ export function buildSessionProto(input: SessionInput): Session {
|
|
|
199
207
|
apiVersion: "agentic.stigmer.ai/v1",
|
|
200
208
|
kind: "Session",
|
|
201
209
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
210
|
+
...(input.id && { id: input.id }),
|
|
202
211
|
name: input.name,
|
|
203
212
|
org: input.org,
|
|
204
213
|
...(input.slug && { slug: input.slug }),
|
|
@@ -220,3 +229,88 @@ export function buildSessionProto(input: SessionInput): Session {
|
|
|
220
229
|
})),
|
|
221
230
|
}) as Session;
|
|
222
231
|
}
|
|
232
|
+
|
|
233
|
+
function toGitRepoSourceInput(msg: GitRepoSource): GitRepoSourceInput {
|
|
234
|
+
return {
|
|
235
|
+
url: msg.url ?? "",
|
|
236
|
+
branch: msg.branch || undefined,
|
|
237
|
+
commit: msg.commit || undefined,
|
|
238
|
+
depth: msg.depth || undefined,
|
|
239
|
+
writeBackMode: msg.writeBackMode || undefined,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function toLocalPathSourceInput(msg: LocalPathSource): LocalPathSourceInput {
|
|
244
|
+
return {
|
|
245
|
+
path: msg.path || undefined,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function toWorkspaceSourceInput(msg: WorkspaceSource): WorkspaceSourceInput {
|
|
250
|
+
return {
|
|
251
|
+
gitRepo: msg.source?.case === "gitRepo" ? toGitRepoSourceInput(msg.source.value) : undefined,
|
|
252
|
+
localPath: msg.source?.case === "localPath" ? toLocalPathSourceInput(msg.source.value) : undefined,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function toWorkspaceEntryInput(msg: WorkspaceEntry): WorkspaceEntryInput {
|
|
257
|
+
return {
|
|
258
|
+
name: msg.name || undefined,
|
|
259
|
+
source: toWorkspaceSourceInput(msg.source ?? create(WorkspaceSourceSchema)),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function toToolApprovalOverrideInput(msg: ToolApprovalOverride): ToolApprovalOverrideInput {
|
|
264
|
+
return {
|
|
265
|
+
toolName: msg.toolName || undefined,
|
|
266
|
+
requiresApproval: msg.requiresApproval || undefined,
|
|
267
|
+
message: msg.message || undefined,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function toMcpServerUsageInput(msg: McpServerUsage): McpServerUsageInput {
|
|
272
|
+
return {
|
|
273
|
+
mcpServerRef: toResourceRefInput(msg.mcpServerRef) ?? { org: "", slug: "" },
|
|
274
|
+
enabledTools: msg.enabledTools?.length ? [...msg.enabledTools] : undefined,
|
|
275
|
+
toolApprovalOverrides: msg.toolApprovalOverrides?.length ? msg.toolApprovalOverrides.map(toToolApprovalOverrideInput) : undefined,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Maps a fetched {@link Session} to a complete {@link SessionInput} for `update()`.
|
|
281
|
+
*
|
|
282
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
283
|
+
* and override only the fields you edit (spread nested objects the same
|
|
284
|
+
* way):
|
|
285
|
+
*
|
|
286
|
+
* await client.update({ ...toSessionUpdateInput(res), description: next });
|
|
287
|
+
*
|
|
288
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
289
|
+
* `version` (pinned refs) and `kind`.
|
|
290
|
+
*/
|
|
291
|
+
export function toSessionUpdateInput(resource: Session): SessionInput {
|
|
292
|
+
const meta = resource.metadata;
|
|
293
|
+
const spec = resource.spec ?? create(SessionSpecSchema);
|
|
294
|
+
return {
|
|
295
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
296
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
297
|
+
// match, so the id is the ONLY working address.
|
|
298
|
+
id: meta?.id || undefined,
|
|
299
|
+
name: meta?.name ?? "",
|
|
300
|
+
slug: meta?.slug || undefined,
|
|
301
|
+
org: meta?.org ?? "",
|
|
302
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
303
|
+
visibility: meta?.visibility || undefined,
|
|
304
|
+
agentInstanceId: spec.agentInstanceId || undefined,
|
|
305
|
+
subject: spec.subject || undefined,
|
|
306
|
+
harnessStateId: spec.harnessStateId || undefined,
|
|
307
|
+
harnessStateIdHistory: spec.harnessStateIdHistory?.length ? [...spec.harnessStateIdHistory] : undefined,
|
|
308
|
+
metadata: Object.keys(spec.metadata ?? {}).length > 0 ? { ...spec.metadata } : undefined,
|
|
309
|
+
workspaceEntries: spec.workspaceEntries?.length ? spec.workspaceEntries.map(toWorkspaceEntryInput) : undefined,
|
|
310
|
+
mcpServerUsages: spec.mcpServerUsages?.length ? spec.mcpServerUsages.map(toMcpServerUsageInput) : undefined,
|
|
311
|
+
skillRefs: toResourceRefInputs(spec.skillRefs),
|
|
312
|
+
harness: spec.harness || undefined,
|
|
313
|
+
cursorMode: spec.cursorMode || undefined,
|
|
314
|
+
executionTarget: spec.executionTarget || undefined,
|
|
315
|
+
};
|
|
316
|
+
}
|
package/src/gen/skill.ts
CHANGED
|
@@ -111,6 +111,14 @@ export class SkillClient {
|
|
|
111
111
|
|
|
112
112
|
/** Input for creating/updating a Skill. */
|
|
113
113
|
export interface SkillInput {
|
|
114
|
+
/**
|
|
115
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
116
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
117
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
118
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
119
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
120
|
+
*/
|
|
121
|
+
id?: string;
|
|
114
122
|
name: string;
|
|
115
123
|
slug?: string;
|
|
116
124
|
org: string;
|
|
@@ -127,6 +135,7 @@ export function buildSkillProto(input: SkillInput): Skill {
|
|
|
127
135
|
apiVersion: "agentic.stigmer.ai/v1",
|
|
128
136
|
kind: "Skill",
|
|
129
137
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
138
|
+
...(input.id && { id: input.id }),
|
|
130
139
|
name: input.name,
|
|
131
140
|
org: input.org,
|
|
132
141
|
...(input.slug && { slug: input.slug }),
|
package/src/gen/workflow.ts
CHANGED
|
@@ -5,14 +5,14 @@ import { stripUndefined } from "./proto-utils.js";
|
|
|
5
5
|
import { type ListParams, type ListResult, type ResourceRef } from "./types.js";
|
|
6
6
|
import { create, type JsonObject } from "@bufbuild/protobuf";
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
|
-
import { EnvVarDeclarationSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
8
|
+
import { EnvVarDeclarationSchema, type EnvVarDeclaration } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
9
9
|
import { WorkflowSchema, type Workflow } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
|
|
10
10
|
import { WorkflowCommandController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/command_pb";
|
|
11
11
|
import { WorkflowTaskKind, BudgetExceededPolicy } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/enum_pb";
|
|
12
12
|
import { WorkflowIdSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/io_pb";
|
|
13
13
|
import { WorkflowQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/query_pb";
|
|
14
14
|
import { type ServerlessWorkflowValidation } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/serverless/validation_pb";
|
|
15
|
-
import { WorkflowSpecSchema, WorkflowDocumentSchema, ExportSchema, FlowControlSchema, WorkflowTaskSchema, WorkflowBudgetSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/spec_pb";
|
|
15
|
+
import { WorkflowSpecSchema, WorkflowDocumentSchema, ExportSchema, FlowControlSchema, WorkflowTaskSchema, WorkflowBudgetSchema, type WorkflowDocument, type Export, type FlowControl, type WorkflowTask, type WorkflowBudget } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/spec_pb";
|
|
16
16
|
import { GetTaskKindRegistryRequestSchema, GetTaskKindRegistryResponseSchema, type GetTaskKindRegistryRequest, type GetTaskKindRegistryResponse } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/task_kind_descriptor_pb";
|
|
17
17
|
import { TaskKindRegistryQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/task_kind_registry_query_pb";
|
|
18
18
|
import { TagWorkflowVersionInputSchema, ListWorkflowVersionsInputSchema, ListWorkflowVersionsResponseSchema, GetWorkflowVersionInputSchema, WorkflowVersionEntrySchema, type TagWorkflowVersionInput, type ListWorkflowVersionsInput, type ListWorkflowVersionsResponse, type GetWorkflowVersionInput, type WorkflowVersionEntry } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/version_pb";
|
|
@@ -131,6 +131,14 @@ export class WorkflowClient {
|
|
|
131
131
|
|
|
132
132
|
/** Input for creating/updating a Workflow. */
|
|
133
133
|
export interface WorkflowInput {
|
|
134
|
+
/**
|
|
135
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
136
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
137
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
138
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
139
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
140
|
+
*/
|
|
141
|
+
id?: string;
|
|
134
142
|
name: string;
|
|
135
143
|
slug?: string;
|
|
136
144
|
org: string;
|
|
@@ -250,6 +258,7 @@ export function buildWorkflowProto(input: WorkflowInput): Workflow {
|
|
|
250
258
|
apiVersion: "agentic.stigmer.ai/v1",
|
|
251
259
|
kind: "Workflow",
|
|
252
260
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
261
|
+
...(input.id && { id: input.id }),
|
|
253
262
|
name: input.name,
|
|
254
263
|
org: input.org,
|
|
255
264
|
...(input.slug && { slug: input.slug }),
|
|
@@ -266,3 +275,88 @@ export function buildWorkflowProto(input: WorkflowInput): Workflow {
|
|
|
266
275
|
})),
|
|
267
276
|
}) as Workflow;
|
|
268
277
|
}
|
|
278
|
+
|
|
279
|
+
function toWorkflowDocumentInput(msg: WorkflowDocument): WorkflowDocumentInput {
|
|
280
|
+
return {
|
|
281
|
+
dsl: msg.dsl || undefined,
|
|
282
|
+
namespace: msg.namespace ?? "",
|
|
283
|
+
name: msg.name ?? "",
|
|
284
|
+
version: msg.version ?? "",
|
|
285
|
+
description: msg.description || undefined,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function toExportInput(msg: Export): ExportInput {
|
|
290
|
+
return {
|
|
291
|
+
as: msg.as || undefined,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function toFlowControlInput(msg: FlowControl): FlowControlInput {
|
|
296
|
+
return {
|
|
297
|
+
then: msg.then || undefined,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function toWorkflowTaskInput(msg: WorkflowTask): WorkflowTaskInput {
|
|
302
|
+
return {
|
|
303
|
+
name: msg.name || undefined,
|
|
304
|
+
kind: msg.kind ?? 0,
|
|
305
|
+
taskConfig: msg.taskConfig ?? {},
|
|
306
|
+
export: msg.export ? toExportInput(msg.export) : undefined,
|
|
307
|
+
flow: msg.flow ? toFlowControlInput(msg.flow) : undefined,
|
|
308
|
+
compensate: msg.compensate?.length ? msg.compensate.map(toWorkflowTaskInput) : undefined,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function toEnvVarDeclarationInput(msg: EnvVarDeclaration): EnvVarDeclarationInput {
|
|
313
|
+
return {
|
|
314
|
+
isSecret: msg.isSecret || undefined,
|
|
315
|
+
description: msg.description || undefined,
|
|
316
|
+
optional: msg.optional || undefined,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function toWorkflowBudgetInput(msg: WorkflowBudget): WorkflowBudgetInput {
|
|
321
|
+
return {
|
|
322
|
+
maxCostMicros: msg.maxCostMicros || undefined,
|
|
323
|
+
maxTotalTokens: msg.maxTotalTokens || undefined,
|
|
324
|
+
maxDurationSeconds: msg.maxDurationSeconds || undefined,
|
|
325
|
+
onExceeded: msg.onExceeded || undefined,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Maps a fetched {@link Workflow} to a complete {@link WorkflowInput} for `update()`.
|
|
331
|
+
*
|
|
332
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
333
|
+
* and override only the fields you edit (spread nested objects the same
|
|
334
|
+
* way):
|
|
335
|
+
*
|
|
336
|
+
* await client.update({ ...toWorkflowUpdateInput(res), description: next });
|
|
337
|
+
*
|
|
338
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
339
|
+
* `version` (pinned refs) and `kind`.
|
|
340
|
+
*/
|
|
341
|
+
export function toWorkflowUpdateInput(resource: Workflow): WorkflowInput {
|
|
342
|
+
const meta = resource.metadata;
|
|
343
|
+
const spec = resource.spec ?? create(WorkflowSpecSchema);
|
|
344
|
+
return {
|
|
345
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
346
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
347
|
+
// match, so the id is the ONLY working address.
|
|
348
|
+
id: meta?.id || undefined,
|
|
349
|
+
name: meta?.name ?? "",
|
|
350
|
+
slug: meta?.slug || undefined,
|
|
351
|
+
org: meta?.org ?? "",
|
|
352
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
353
|
+
visibility: meta?.visibility || undefined,
|
|
354
|
+
// Never carried over: a version message describes the NEXT update.
|
|
355
|
+
versionMessage: undefined,
|
|
356
|
+
description: spec.description || undefined,
|
|
357
|
+
document: toWorkflowDocumentInput(spec.document ?? create(WorkflowDocumentSchema)),
|
|
358
|
+
tasks: spec.tasks?.length ? spec.tasks.map(toWorkflowTaskInput) : undefined,
|
|
359
|
+
env: Object.keys(spec.env ?? {}).length > 0 ? Object.fromEntries(Object.entries(spec.env).map(([k, v]) => [k, toEnvVarDeclarationInput(v)])) : undefined,
|
|
360
|
+
budget: spec.budget ? toWorkflowBudgetInput(spec.budget) : undefined,
|
|
361
|
+
};
|
|
362
|
+
}
|