@stigmer/sdk 3.5.3 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/manifest.test.js +65 -1
- package/__tests__/manifest.test.js.map +1 -1
- package/gen/agentchannel.d.ts +12 -1
- package/gen/agentchannel.d.ts.map +1 -1
- package/gen/agentchannel.js +70 -0
- package/gen/agentchannel.js.map +1 -1
- package/gen/agentexecution.d.ts +2 -1
- package/gen/agentexecution.d.ts.map +1 -1
- package/gen/agentexecution.js +2 -0
- package/gen/agentexecution.js.map +1 -1
- package/gen/authorization-config.d.ts.map +1 -1
- package/gen/authorization-config.js +2 -1
- package/gen/authorization-config.js.map +1 -1
- package/gen/client.d.ts +4 -0
- package/gen/client.d.ts.map +1 -1
- package/gen/client.js +4 -0
- package/gen/client.js.map +1 -1
- package/gen/schedule.d.ts +76 -0
- package/gen/schedule.d.ts.map +1 -0
- package/gen/schedule.js +191 -0
- package/gen/schedule.js.map +1 -0
- package/iam-role.d.ts.map +1 -1
- package/iam-role.js +4 -0
- package/iam-role.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/manifest/document.d.ts +31 -0
- package/manifest/document.d.ts.map +1 -0
- package/manifest/document.js +62 -0
- package/manifest/document.js.map +1 -0
- package/manifest/index.d.ts +1 -0
- package/manifest/index.d.ts.map +1 -1
- package/manifest/index.js +1 -0
- package/manifest/index.js.map +1 -1
- package/manifest/registry.d.ts.map +1 -1
- package/manifest/registry.js +16 -1
- package/manifest/registry.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/manifest.test.ts +78 -1
- package/src/gen/agentchannel.ts +56 -1
- package/src/gen/agentexecution.ts +3 -1
- package/src/gen/authorization-config.ts +2 -1
- package/src/gen/client.ts +5 -0
- package/src/gen/schedule.ts +230 -0
- package/src/iam-role.ts +4 -0
- package/src/index.ts +8 -0
- package/src/manifest/document.ts +70 -0
- package/src/manifest/index.ts +2 -0
- package/src/manifest/registry.ts +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stigmer/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Stigmer TypeScript SDK — typed API client for all Stigmer platform resources",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@bufbuild/protobuf": "^2.0.0",
|
|
47
47
|
"@connectrpc/connect-node": "^2.0.0",
|
|
48
|
-
"@stigmer/protos": "3.
|
|
48
|
+
"@stigmer/protos": "3.7.0"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { create, equals } from "@bufbuild/protobuf";
|
|
2
|
+
import { clone, create, equals } from "@bufbuild/protobuf";
|
|
3
3
|
import { AgentSchema, type Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
4
4
|
import { EnvironmentSchema, type Environment } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/api_pb";
|
|
5
|
+
import { ScheduleSchema, type Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
|
|
6
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
5
7
|
import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
6
8
|
import { parse as parseYaml } from "yaml";
|
|
7
9
|
import { parseManifest } from "../manifest/parse";
|
|
8
10
|
import { serializeManifest } from "../manifest/serialize";
|
|
11
|
+
import { manifestDocumentForResource } from "../manifest/document";
|
|
9
12
|
import { manifestKinds, manifestHandlerForYamlKind } from "../manifest/registry";
|
|
10
13
|
|
|
11
14
|
/**
|
|
@@ -245,6 +248,80 @@ describe("serializeManifest", () => {
|
|
|
245
248
|
});
|
|
246
249
|
});
|
|
247
250
|
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// manifestDocumentForResource
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
|
|
255
|
+
describe("manifestDocumentForResource", () => {
|
|
256
|
+
// Shaped like a server-returned schedule: full metadata (including
|
|
257
|
+
// fields the curated ScheduleInput cannot express, like tags) and a
|
|
258
|
+
// populated status — the exact input of a lossless partial edit.
|
|
259
|
+
const schedule = create(ScheduleSchema, {
|
|
260
|
+
apiVersion: "agentic.stigmer.ai/v1",
|
|
261
|
+
kind: "Schedule",
|
|
262
|
+
metadata: {
|
|
263
|
+
id: "sch_01example",
|
|
264
|
+
name: "daily-fee-reminders",
|
|
265
|
+
slug: "daily-fee-reminders",
|
|
266
|
+
org: "isc",
|
|
267
|
+
tags: ["billing"],
|
|
268
|
+
labels: { team: "ops" },
|
|
269
|
+
},
|
|
270
|
+
spec: {
|
|
271
|
+
cron: "0 9 * * *",
|
|
272
|
+
timeZone: "Asia/Kolkata",
|
|
273
|
+
enabled: true,
|
|
274
|
+
target: {
|
|
275
|
+
case: "agent",
|
|
276
|
+
value: {
|
|
277
|
+
agentRef: { kind: ApiResourceKind.agent, org: "isc", slug: "fee-reminder" },
|
|
278
|
+
message: "Send today's fee reminders.",
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
status: { consecutiveFailures: 2, pausedReason: "" },
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("wraps a fetched proto untouched — the lossless edit contract", () => {
|
|
286
|
+
const flipped = clone(ScheduleSchema, schedule);
|
|
287
|
+
flipped.spec!.enabled = false;
|
|
288
|
+
|
|
289
|
+
const doc = manifestDocumentForResource(flipped);
|
|
290
|
+
|
|
291
|
+
expect(doc.handler.yamlKind).toBe("Schedule");
|
|
292
|
+
expect(doc.name).toBe("daily-fee-reminders");
|
|
293
|
+
expect(doc.slug).toBe("daily-fee-reminders");
|
|
294
|
+
expect(doc.org).toBe("isc");
|
|
295
|
+
// Identity, not a copy: nothing is re-serialized or down-converted,
|
|
296
|
+
// so every field survives (the ScheduleInput path would drop tags).
|
|
297
|
+
expect(doc.message).toBe(flipped);
|
|
298
|
+
|
|
299
|
+
const expected = clone(ScheduleSchema, schedule);
|
|
300
|
+
expected.spec!.enabled = false;
|
|
301
|
+
expect(equals(ScheduleSchema, doc.message as Schedule, expected)).toBe(true);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it("falls back to name when the proto has no slug", () => {
|
|
305
|
+
const bare = create(AgentSchema, { metadata: { name: "x", org: "acme" } });
|
|
306
|
+
const doc = manifestDocumentForResource(bare);
|
|
307
|
+
expect(doc.slug).toBe("x");
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("rejects messages of kinds outside the registry", () => {
|
|
311
|
+
const notAResource = create(ApiResourceMetadataSchema, { name: "x" });
|
|
312
|
+
expect(() => manifestDocumentForResource(notAResource)).toThrow(
|
|
313
|
+
/not.*registry/i,
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it("rejects a resource without metadata.name", () => {
|
|
318
|
+
const nameless = create(ScheduleSchema, { metadata: { org: "acme" } });
|
|
319
|
+
expect(() => manifestDocumentForResource(nameless)).toThrow(
|
|
320
|
+
/metadata\.name/,
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
248
325
|
// ---------------------------------------------------------------------------
|
|
249
326
|
// Registry invariants
|
|
250
327
|
// ---------------------------------------------------------------------------
|
package/src/gen/agentchannel.ts
CHANGED
|
@@ -7,9 +7,12 @@ import { create } from "@bufbuild/protobuf";
|
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
8
|
import { AgentChannelSchema, type AgentChannel } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/api_pb";
|
|
9
9
|
import { AgentChannelCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/command_pb";
|
|
10
|
+
import { ChannelConversationCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_command_pb";
|
|
11
|
+
import { ReplyToConversationInputSchema, ConversationControlInputSchema, ChannelConversationSchema, EscalateConversationInputSchema, ListChannelConversationsInputSchema, ChannelConversationListSchema, GetConversationTimelineInputSchema, ConversationTimelineSchema, type ReplyToConversationInput, type ConversationControlInput, type ChannelConversation, type EscalateConversationInput, type ListChannelConversationsInput, type ChannelConversationList, type GetConversationTimelineInput, type ConversationTimeline } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
|
|
12
|
+
import { ChannelConversationQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_query_pb";
|
|
10
13
|
import { AgentChannelIdSchema, InitiateChannelInstallInputSchema, InitiateChannelInstallOutputSchema, CompleteChannelInstallInputSchema, GetAgentChannelsByAgentRequestSchema, AgentChannelListSchema, ListAgentChannelsRequestSchema, type InitiateChannelInstallInput, type InitiateChannelInstallOutput, type CompleteChannelInstallInput, type GetAgentChannelsByAgentRequest, type AgentChannelList, type ListAgentChannelsRequest } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/io_pb";
|
|
11
14
|
import { ChannelMessageCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_command_pb";
|
|
12
|
-
import {
|
|
15
|
+
import { SendChannelMessageOutputSchema, SendChannelMessageInputSchema, ListChannelTemplatesInputSchema, ChannelTemplatesSchema, ListMessagingChannelsInputSchema, MessagingChannelsSchema, type SendChannelMessageOutput, type SendChannelMessageInput, type ListChannelTemplatesInput, type ChannelTemplates, type ListMessagingChannelsInput, type MessagingChannels } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_io_pb";
|
|
13
16
|
import { ChannelMessageQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_query_pb";
|
|
14
17
|
import { AgentChannelQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/query_pb";
|
|
15
18
|
import { AgentChannelSpecSchema, SlackChannelConfigSchema, WhatsAppChannelConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/spec_pb";
|
|
@@ -21,12 +24,16 @@ import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/ap
|
|
|
21
24
|
/** Provides operations on agentchannel resources. */
|
|
22
25
|
export class AgentChannelClient {
|
|
23
26
|
private readonly command: Client<typeof AgentChannelCommandController>;
|
|
27
|
+
private readonly channelConversationCommand: Client<typeof ChannelConversationCommandController>;
|
|
28
|
+
private readonly channelConversationQuery: Client<typeof ChannelConversationQueryController>;
|
|
24
29
|
private readonly channelMessageCommand: Client<typeof ChannelMessageCommandController>;
|
|
25
30
|
private readonly channelMessageQuery: Client<typeof ChannelMessageQueryController>;
|
|
26
31
|
private readonly query: Client<typeof AgentChannelQueryController>;
|
|
27
32
|
|
|
28
33
|
constructor(transport: Transport) {
|
|
29
34
|
this.command = createClient(AgentChannelCommandController, transport);
|
|
35
|
+
this.channelConversationCommand = createClient(ChannelConversationCommandController, transport);
|
|
36
|
+
this.channelConversationQuery = createClient(ChannelConversationQueryController, transport);
|
|
30
37
|
this.channelMessageCommand = createClient(ChannelMessageCommandController, transport);
|
|
31
38
|
this.channelMessageQuery = createClient(ChannelMessageQueryController, transport);
|
|
32
39
|
this.query = createClient(AgentChannelQueryController, transport);
|
|
@@ -68,6 +75,48 @@ export class AgentChannelClient {
|
|
|
68
75
|
} catch (e) { throw wrapError(e); }
|
|
69
76
|
}
|
|
70
77
|
|
|
78
|
+
async reply(input: ReplyToConversationInput): Promise<SendChannelMessageOutput> {
|
|
79
|
+
try {
|
|
80
|
+
return await this.channelConversationCommand.reply(input);
|
|
81
|
+
} catch (e) { throw wrapError(e); }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async takeOver(input: ConversationControlInput): Promise<ChannelConversation> {
|
|
85
|
+
try {
|
|
86
|
+
return await this.channelConversationCommand.takeOver(input);
|
|
87
|
+
} catch (e) { throw wrapError(e); }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async handBack(input: ConversationControlInput): Promise<ChannelConversation> {
|
|
91
|
+
try {
|
|
92
|
+
return await this.channelConversationCommand.handBack(input);
|
|
93
|
+
} catch (e) { throw wrapError(e); }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async clearAttention(input: ConversationControlInput): Promise<ChannelConversation> {
|
|
97
|
+
try {
|
|
98
|
+
return await this.channelConversationCommand.clearAttention(input);
|
|
99
|
+
} catch (e) { throw wrapError(e); }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async escalate(input: EscalateConversationInput): Promise<ChannelConversation> {
|
|
103
|
+
try {
|
|
104
|
+
return await this.channelConversationCommand.escalate(input);
|
|
105
|
+
} catch (e) { throw wrapError(e); }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async listConversations(input: ListChannelConversationsInput): Promise<ChannelConversationList> {
|
|
109
|
+
try {
|
|
110
|
+
return await this.channelConversationQuery.listConversations(input);
|
|
111
|
+
} catch (e) { throw wrapError(e); }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async getTimeline(input: GetConversationTimelineInput): Promise<ConversationTimeline> {
|
|
115
|
+
try {
|
|
116
|
+
return await this.channelConversationQuery.getTimeline(input);
|
|
117
|
+
} catch (e) { throw wrapError(e); }
|
|
118
|
+
}
|
|
119
|
+
|
|
71
120
|
async sendMessage(input: SendChannelMessageInput): Promise<SendChannelMessageOutput> {
|
|
72
121
|
try {
|
|
73
122
|
return await this.channelMessageCommand.sendMessage(input);
|
|
@@ -80,6 +129,12 @@ export class AgentChannelClient {
|
|
|
80
129
|
} catch (e) { throw wrapError(e); }
|
|
81
130
|
}
|
|
82
131
|
|
|
132
|
+
async listMessagingChannels(input: ListMessagingChannelsInput): Promise<MessagingChannels> {
|
|
133
|
+
try {
|
|
134
|
+
return await this.channelMessageQuery.listMessagingChannels(input);
|
|
135
|
+
} catch (e) { throw wrapError(e); }
|
|
136
|
+
}
|
|
137
|
+
|
|
83
138
|
async get(id: string): Promise<AgentChannel> {
|
|
84
139
|
try {
|
|
85
140
|
return await this.query.get(create(AgentChannelIdSchema, { value: id }));
|
|
@@ -8,7 +8,7 @@ import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
|
8
8
|
import { ToolApprovalOverrideSchema, McpServerUsageSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
|
|
9
9
|
import { AgentExecutionSchema, type AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
10
10
|
import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/command_pb";
|
|
11
|
-
import { InteractionMode, ApprovalMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
11
|
+
import { InteractionMode, ApprovalMode, ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
12
12
|
import { AgentExecutionIdSchema, AgentExecutionUpdateStatusInputSchema, UpdateStatusResponseSchema, SubmitApprovalInputSchema, SubmitFileDecisionInputSchema, CancelAgentExecutionInputSchema, TerminateAgentExecutionInputSchema, RecoverAgentExecutionInputSchema, PauseAgentExecutionInputSchema, ResumeAgentExecutionInputSchema, UploadAttachmentRequestSchema, UploadAttachmentResponseSchema, ListAgentExecutionsRequestSchema, AgentExecutionListSchema, ListAgentExecutionsBySessionRequestSchema, GetArtifactDownloadUrlRequestSchema, GetArtifactDownloadUrlResponseSchema, GetArtifactContentRequestSchema, GetArtifactContentResponseSchema, GetExecutionUsageReportInputSchema, GetExecutionUsageReportOutputSchema, GetSessionUsageReportInputSchema, GetSessionUsageReportOutputSchema, GetAgentUsageReportInputSchema, GetAgentUsageReportOutputSchema, GetOrgUsageReportInputSchema, GetOrgUsageReportOutputSchema, GetAgentExecutionSummaryRequestSchema, AgentExecutionSummarySchema, type AgentExecutionUpdateStatusInput, type UpdateStatusResponse, type SubmitApprovalInput, type SubmitFileDecisionInput, type CancelAgentExecutionInput, type TerminateAgentExecutionInput, type RecoverAgentExecutionInput, type PauseAgentExecutionInput, type ResumeAgentExecutionInput, type UploadAttachmentRequest, type UploadAttachmentResponse, type ListAgentExecutionsRequest, type AgentExecutionList, type ListAgentExecutionsBySessionRequest, type GetArtifactDownloadUrlRequest, type GetArtifactDownloadUrlResponse, type GetArtifactContentRequest, type GetArtifactContentResponse, type GetExecutionUsageReportInput, type GetExecutionUsageReportOutput, type GetSessionUsageReportInput, type GetSessionUsageReportOutput, type GetAgentUsageReportInput, type GetAgentUsageReportOutput, type GetOrgUsageReportInput, type GetOrgUsageReportOutput, type GetAgentExecutionSummaryRequest, type AgentExecutionSummary } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/io_pb";
|
|
13
13
|
import { AgentExecutionQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/query_pb";
|
|
14
14
|
import { AgentExecutionSpecSchema, ContextManagementConfigSchema, ExecutionConfigSchema, AttachmentSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
|
|
@@ -259,6 +259,7 @@ export interface ExecutionConfigInput {
|
|
|
259
259
|
structuredOutputSchema?: JsonObject;
|
|
260
260
|
buildFromPlan?: boolean;
|
|
261
261
|
approvalMode?: ApprovalMode;
|
|
262
|
+
serviceTier?: ServiceTier;
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
/** SDK input type for ContextManagementConfig. */
|
|
@@ -362,6 +363,7 @@ function buildExecutionConfigProto(input: ExecutionConfigInput) {
|
|
|
362
363
|
if (input.structuredOutputSchema !== undefined) msg.structuredOutputSchema = input.structuredOutputSchema;
|
|
363
364
|
if (input.buildFromPlan !== undefined) msg.buildFromPlan = input.buildFromPlan;
|
|
364
365
|
if (input.approvalMode !== undefined) msg.approvalMode = input.approvalMode;
|
|
366
|
+
if (input.serviceTier !== undefined) msg.serviceTier = input.serviceTier;
|
|
365
367
|
return msg;
|
|
366
368
|
}
|
|
367
369
|
|
|
@@ -24,7 +24,7 @@ export const GRANTABLE_ROLES: ReadonlyMap<ApiResourceKind, readonly IamRole[]> =
|
|
|
24
24
|
[ApiResourceKind.mcp_server, [IamRole.owner, IamRole.viewer]],
|
|
25
25
|
[ApiResourceKind.agent_instance, [IamRole.owner, IamRole.viewer]],
|
|
26
26
|
[ApiResourceKind.agent_share, [IamRole.owner, IamRole.viewer]],
|
|
27
|
-
[ApiResourceKind.agent_channel, [IamRole.owner, IamRole.viewer]],
|
|
27
|
+
[ApiResourceKind.agent_channel, [IamRole.owner, IamRole.viewer, IamRole.participant]],
|
|
28
28
|
[ApiResourceKind.channel_app, [IamRole.owner, IamRole.viewer]],
|
|
29
29
|
[ApiResourceKind.datastore, [IamRole.owner, IamRole.viewer]],
|
|
30
30
|
[ApiResourceKind.workflow, [IamRole.owner, IamRole.viewer]],
|
|
@@ -32,5 +32,6 @@ export const GRANTABLE_ROLES: ReadonlyMap<ApiResourceKind, readonly IamRole[]> =
|
|
|
32
32
|
[ApiResourceKind.workflow_execution, [IamRole.owner, IamRole.viewer]],
|
|
33
33
|
[ApiResourceKind.environment, [IamRole.owner, IamRole.viewer]],
|
|
34
34
|
[ApiResourceKind.artifact, [IamRole.owner, IamRole.viewer]],
|
|
35
|
+
[ApiResourceKind.schedule, [IamRole.owner, IamRole.viewer]],
|
|
35
36
|
[ApiResourceKind.project, [IamRole.owner, IamRole.viewer]],
|
|
36
37
|
]);
|
package/src/gen/client.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { OAuthAppClient } from "./oauthapp.js";
|
|
|
21
21
|
import { OrganizationClient } from "./organization.js";
|
|
22
22
|
import { PlatformClientClient } from "./platformclient.js";
|
|
23
23
|
import { ProjectClient } from "./project.js";
|
|
24
|
+
import { ScheduleClient } from "./schedule.js";
|
|
24
25
|
import { SessionClient } from "./session.js";
|
|
25
26
|
import { SkillClient } from "./skill.js";
|
|
26
27
|
import { WorkflowClient } from "./workflow.js";
|
|
@@ -49,6 +50,7 @@ export class GeneratedClient {
|
|
|
49
50
|
readonly organization: OrganizationClient;
|
|
50
51
|
readonly platformclient: PlatformClientClient;
|
|
51
52
|
readonly project: ProjectClient;
|
|
53
|
+
readonly schedule: ScheduleClient;
|
|
52
54
|
readonly session: SessionClient;
|
|
53
55
|
readonly skill: SkillClient;
|
|
54
56
|
readonly workflow: WorkflowClient;
|
|
@@ -76,6 +78,7 @@ export class GeneratedClient {
|
|
|
76
78
|
this.organization = new OrganizationClient(transport);
|
|
77
79
|
this.platformclient = new PlatformClientClient(transport);
|
|
78
80
|
this.project = new ProjectClient(transport);
|
|
81
|
+
this.schedule = new ScheduleClient(transport);
|
|
79
82
|
this.session = new SessionClient(transport);
|
|
80
83
|
this.skill = new SkillClient(transport);
|
|
81
84
|
this.workflow = new WorkflowClient(transport);
|
|
@@ -125,6 +128,8 @@ export { PlatformClientClient } from "./platformclient.js";
|
|
|
125
128
|
export { type PlatformClientInput } from "./platformclient.js";
|
|
126
129
|
export { ProjectClient } from "./project.js";
|
|
127
130
|
export { type ProjectInput } from "./project.js";
|
|
131
|
+
export { ScheduleClient } from "./schedule.js";
|
|
132
|
+
export { type ScheduleInput, type AgentInvocationInput, type RunConfigInput } from "./schedule.js";
|
|
128
133
|
export { SessionClient } from "./session.js";
|
|
129
134
|
export { type SessionInput } from "./session.js";
|
|
130
135
|
export { SkillClient } from "./skill.js";
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import { wrapError } from "./errors.js";
|
|
4
|
+
import { stripUndefined } from "./proto-utils.js";
|
|
5
|
+
import { type ResourceRef } from "./types.js";
|
|
6
|
+
import { create } from "@bufbuild/protobuf";
|
|
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";
|
|
10
|
+
import { ScheduleSchema, type Schedule } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
|
|
11
|
+
import { ScheduleCommandController } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/command_pb";
|
|
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
|
+
import { ScheduleQueryController } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/query_pb";
|
|
14
|
+
import { ScheduleSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/spec_pb";
|
|
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";
|
|
17
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
18
|
+
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
19
|
+
import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
20
|
+
import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
21
|
+
|
|
22
|
+
/** Provides operations on schedule resources. */
|
|
23
|
+
export class ScheduleClient {
|
|
24
|
+
private readonly command: Client<typeof ScheduleCommandController>;
|
|
25
|
+
private readonly query: Client<typeof ScheduleQueryController>;
|
|
26
|
+
|
|
27
|
+
constructor(transport: Transport) {
|
|
28
|
+
this.command = createClient(ScheduleCommandController, transport);
|
|
29
|
+
this.query = createClient(ScheduleQueryController, transport);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async apply(input: ScheduleInput): Promise<Schedule> {
|
|
33
|
+
try {
|
|
34
|
+
return await this.command.apply(buildScheduleProto(input));
|
|
35
|
+
} catch (e) { throw wrapError(e); }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async create(input: ScheduleInput): Promise<Schedule> {
|
|
39
|
+
try {
|
|
40
|
+
return await this.command.create(buildScheduleProto(input));
|
|
41
|
+
} catch (e) { throw wrapError(e); }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async update(input: ScheduleInput): Promise<Schedule> {
|
|
45
|
+
try {
|
|
46
|
+
return await this.command.update(buildScheduleProto(input));
|
|
47
|
+
} catch (e) { throw wrapError(e); }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async delete(id: string): Promise<Schedule> {
|
|
51
|
+
try {
|
|
52
|
+
return await this.command.delete(create(ScheduleIdSchema, { value: id }));
|
|
53
|
+
} catch (e) { throw wrapError(e); }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async resume(id: string): Promise<Schedule> {
|
|
57
|
+
try {
|
|
58
|
+
return await this.command.resume(create(ScheduleIdSchema, { value: id }));
|
|
59
|
+
} catch (e) { throw wrapError(e); }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async trigger(id: string): Promise<ScheduleTriggerResult> {
|
|
63
|
+
try {
|
|
64
|
+
return await this.command.trigger(create(ScheduleIdSchema, { value: id }));
|
|
65
|
+
} catch (e) { throw wrapError(e); }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async get(id: string): Promise<Schedule> {
|
|
69
|
+
try {
|
|
70
|
+
return await this.query.get(create(ScheduleIdSchema, { value: id }));
|
|
71
|
+
} catch (e) { throw wrapError(e); }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async getByReference(ref: ResourceRef): Promise<Schedule> {
|
|
75
|
+
try {
|
|
76
|
+
return await this.query.getByReference(create(ApiResourceReferenceSchema, { ...ref, kind: ApiResourceKind.schedule }));
|
|
77
|
+
} catch (e) { throw wrapError(e); }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async getByAgent(input: GetSchedulesByAgentRequest): Promise<ScheduleList> {
|
|
81
|
+
try {
|
|
82
|
+
return await this.query.getByAgent(input);
|
|
83
|
+
} catch (e) { throw wrapError(e); }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async list(input: ListSchedulesRequest): Promise<ScheduleList> {
|
|
87
|
+
try {
|
|
88
|
+
return await this.query.list(input);
|
|
89
|
+
} catch (e) { throw wrapError(e); }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async listRuns(input: ListScheduleRunsRequest): Promise<ScheduleRunList> {
|
|
93
|
+
try {
|
|
94
|
+
return await this.query.listRuns(input);
|
|
95
|
+
} catch (e) { throw wrapError(e); }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Input for creating/updating a Schedule. */
|
|
100
|
+
export interface ScheduleInput {
|
|
101
|
+
name: string;
|
|
102
|
+
slug?: string;
|
|
103
|
+
org: string;
|
|
104
|
+
labels?: Record<string, string>;
|
|
105
|
+
visibility?: ApiResourceVisibility;
|
|
106
|
+
cron?: string;
|
|
107
|
+
timeZone?: string;
|
|
108
|
+
enabled?: boolean;
|
|
109
|
+
agent?: AgentInvocationInput;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** SDK input type for AgentInvocation. */
|
|
113
|
+
export interface AgentInvocationInput {
|
|
114
|
+
agentRef: ResourceRef;
|
|
115
|
+
message?: string;
|
|
116
|
+
harness?: Harness;
|
|
117
|
+
workspaceEntries?: WorkspaceEntryInput[];
|
|
118
|
+
environmentRefs?: ResourceRef[];
|
|
119
|
+
runConfig?: RunConfigInput;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** SDK input type for WorkspaceEntry. */
|
|
123
|
+
export interface WorkspaceEntryInput {
|
|
124
|
+
name?: string;
|
|
125
|
+
source: WorkspaceSourceInput;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** SDK input type for WorkspaceSource. */
|
|
129
|
+
export interface WorkspaceSourceInput {
|
|
130
|
+
gitRepo?: GitRepoSourceInput;
|
|
131
|
+
localPath?: LocalPathSourceInput;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** SDK input type for GitRepoSource. */
|
|
135
|
+
export interface GitRepoSourceInput {
|
|
136
|
+
url: string;
|
|
137
|
+
branch?: string;
|
|
138
|
+
commit?: string;
|
|
139
|
+
depth?: number;
|
|
140
|
+
writeBackMode?: GitWriteBackMode;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** SDK input type for LocalPathSource. */
|
|
144
|
+
export interface LocalPathSourceInput {
|
|
145
|
+
path?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** SDK input type for RunConfig. */
|
|
149
|
+
export interface RunConfigInput {
|
|
150
|
+
modelName?: string;
|
|
151
|
+
maxCostUsd?: number;
|
|
152
|
+
maxToolRounds?: number;
|
|
153
|
+
serviceTier?: ServiceTier;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function buildGitRepoSourceProto(input: GitRepoSourceInput) {
|
|
157
|
+
return Object.assign(create(GitRepoSourceSchema), stripUndefined({
|
|
158
|
+
url: input.url,
|
|
159
|
+
branch: input.branch,
|
|
160
|
+
commit: input.commit,
|
|
161
|
+
depth: input.depth,
|
|
162
|
+
writeBackMode: input.writeBackMode,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function buildLocalPathSourceProto(input: LocalPathSourceInput) {
|
|
167
|
+
return Object.assign(create(LocalPathSourceSchema), stripUndefined({
|
|
168
|
+
path: input.path,
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function buildWorkspaceSourceProto(input: WorkspaceSourceInput) {
|
|
173
|
+
const msg = create(WorkspaceSourceSchema);
|
|
174
|
+
if (input.gitRepo) {
|
|
175
|
+
msg.source = { case: "gitRepo", value: buildGitRepoSourceProto(input.gitRepo) };
|
|
176
|
+
} else if (input.localPath) {
|
|
177
|
+
msg.source = { case: "localPath", value: buildLocalPathSourceProto(input.localPath) };
|
|
178
|
+
}
|
|
179
|
+
return msg;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function buildWorkspaceEntryProto(input: WorkspaceEntryInput) {
|
|
183
|
+
const msg = create(WorkspaceEntrySchema);
|
|
184
|
+
if (input.name !== undefined) msg.name = input.name;
|
|
185
|
+
if (input.source) msg.source = buildWorkspaceSourceProto(input.source);
|
|
186
|
+
return msg;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function buildRunConfigProto(input: RunConfigInput) {
|
|
190
|
+
return Object.assign(create(RunConfigSchema), stripUndefined({
|
|
191
|
+
modelName: input.modelName,
|
|
192
|
+
maxCostUsd: input.maxCostUsd,
|
|
193
|
+
maxToolRounds: input.maxToolRounds,
|
|
194
|
+
serviceTier: input.serviceTier,
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function buildAgentInvocationProto(input: AgentInvocationInput) {
|
|
199
|
+
const msg = create(AgentInvocationSchema);
|
|
200
|
+
if (input.agentRef?.slug || input.agentRef?.org) msg.agentRef = create(ApiResourceReferenceSchema, { ...input.agentRef, kind: 40 });
|
|
201
|
+
if (input.message !== undefined) msg.message = input.message;
|
|
202
|
+
if (input.harness !== undefined) msg.harness = input.harness;
|
|
203
|
+
if (input.workspaceEntries) msg.workspaceEntries = input.workspaceEntries.map(buildWorkspaceEntryProto);
|
|
204
|
+
if (input.environmentRefs) msg.environmentRefs = input.environmentRefs.map(r => create(ApiResourceReferenceSchema, { ...r, kind: 53 }));
|
|
205
|
+
if (input.runConfig) msg.runConfig = buildRunConfigProto(input.runConfig);
|
|
206
|
+
return msg;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function buildScheduleProto(input: ScheduleInput): Schedule {
|
|
210
|
+
const spec = Object.assign(create(ScheduleSpecSchema), stripUndefined({
|
|
211
|
+
cron: input.cron,
|
|
212
|
+
timeZone: input.timeZone,
|
|
213
|
+
enabled: input.enabled,
|
|
214
|
+
}));
|
|
215
|
+
if (input.agent) {
|
|
216
|
+
spec.target = { case: "agent", value: buildAgentInvocationProto(input.agent) };
|
|
217
|
+
}
|
|
218
|
+
return Object.assign(create(ScheduleSchema), {
|
|
219
|
+
apiVersion: "agentic.stigmer.ai/v1",
|
|
220
|
+
kind: "Schedule",
|
|
221
|
+
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
222
|
+
name: input.name,
|
|
223
|
+
org: input.org,
|
|
224
|
+
...(input.slug && { slug: input.slug }),
|
|
225
|
+
...(input.labels && { labels: input.labels }),
|
|
226
|
+
...(input.visibility && { visibility: input.visibility }),
|
|
227
|
+
}),
|
|
228
|
+
spec,
|
|
229
|
+
}) as Schedule;
|
|
230
|
+
}
|
package/src/iam-role.ts
CHANGED
|
@@ -6,6 +6,7 @@ const ROLE_STRINGS: Record<IamRole, string> = {
|
|
|
6
6
|
[IamRole.admin]: "admin",
|
|
7
7
|
[IamRole.member]: "member",
|
|
8
8
|
[IamRole.viewer]: "viewer",
|
|
9
|
+
[IamRole.participant]: "participant",
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
const STRING_TO_ROLE: Record<string, IamRole> = {
|
|
@@ -13,6 +14,7 @@ const STRING_TO_ROLE: Record<string, IamRole> = {
|
|
|
13
14
|
admin: IamRole.admin,
|
|
14
15
|
member: IamRole.member,
|
|
15
16
|
viewer: IamRole.viewer,
|
|
17
|
+
participant: IamRole.participant,
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
const ROLE_DISPLAY_NAMES: Record<IamRole, string> = {
|
|
@@ -21,6 +23,7 @@ const ROLE_DISPLAY_NAMES: Record<IamRole, string> = {
|
|
|
21
23
|
[IamRole.admin]: "Admin",
|
|
22
24
|
[IamRole.member]: "Member",
|
|
23
25
|
[IamRole.viewer]: "Viewer",
|
|
26
|
+
[IamRole.participant]: "Participant",
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
const ROLE_DESCRIPTIONS: Record<IamRole, string> = {
|
|
@@ -29,6 +32,7 @@ const ROLE_DESCRIPTIONS: Record<IamRole, string> = {
|
|
|
29
32
|
[IamRole.admin]: "Edit access and member management",
|
|
30
33
|
[IamRole.member]: "Standard access to organization resources",
|
|
31
34
|
[IamRole.viewer]: "Read-only access",
|
|
35
|
+
[IamRole.participant]: "Reply to customers and manage conversation takeover",
|
|
32
36
|
};
|
|
33
37
|
|
|
34
38
|
/**
|
package/src/index.ts
CHANGED
|
@@ -132,6 +132,7 @@ export {
|
|
|
132
132
|
ManifestClient,
|
|
133
133
|
parseManifest,
|
|
134
134
|
serializeManifest,
|
|
135
|
+
manifestDocumentForResource,
|
|
135
136
|
manifestKinds,
|
|
136
137
|
manifestHandlerForYamlKind,
|
|
137
138
|
manifestHandlerForTypeName,
|
|
@@ -240,6 +241,13 @@ export {
|
|
|
240
241
|
type PlatformClientInput,
|
|
241
242
|
} from "./gen/platformclient.js";
|
|
242
243
|
export { ProjectClient, type ProjectInput } from "./gen/project.js";
|
|
244
|
+
export {
|
|
245
|
+
ScheduleClient,
|
|
246
|
+
buildScheduleProto,
|
|
247
|
+
type ScheduleInput,
|
|
248
|
+
type AgentInvocationInput,
|
|
249
|
+
type RunConfigInput,
|
|
250
|
+
} from "./gen/schedule.js";
|
|
243
251
|
export {
|
|
244
252
|
SessionClient,
|
|
245
253
|
type SessionInput,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Build a ManifestDocument directly from a live resource proto.
|
|
2
|
+
//
|
|
3
|
+
// The programmatic sibling of `parseManifest`: where parsing starts from
|
|
4
|
+
// YAML text, this starts from a proto the server already returned (a
|
|
5
|
+
// `get`/`getByReference` result). It exists for lossless partial edits —
|
|
6
|
+
// clone the fetched proto, change one field, apply the whole thing — so
|
|
7
|
+
// callers never have to down-convert a proto into a curated `*Input`
|
|
8
|
+
// shape (which cannot express every metadata field and would silently
|
|
9
|
+
// drop the ones it can't carry).
|
|
10
|
+
|
|
11
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
12
|
+
import { metadataOf, type ManifestDocument } from "./parse.js";
|
|
13
|
+
import { manifestHandlerForTypeName, manifestKinds } from "./registry.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Wrap a resource proto as a {@link ManifestDocument} ready for
|
|
17
|
+
* `stigmer.manifest.apply()`.
|
|
18
|
+
*
|
|
19
|
+
* The resource kind is derived from the message's proto type, so any
|
|
20
|
+
* registry-supported resource works with the same call. The message is
|
|
21
|
+
* passed through untouched — full fidelity, no serialization round-trip.
|
|
22
|
+
* The server ignores client-provided `status` on apply, so a fetched
|
|
23
|
+
* proto (status included) is safe to send as-is.
|
|
24
|
+
*
|
|
25
|
+
* @param message - A resource proto of a registry-supported kind, with
|
|
26
|
+
* `metadata.name` set (always true for server-returned resources).
|
|
27
|
+
* @returns A document ready for `ManifestClient.apply`.
|
|
28
|
+
* @throws {Error} When the message's kind is not in the manifest
|
|
29
|
+
* registry, or the message has no `metadata.name`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { clone } from "@bufbuild/protobuf";
|
|
34
|
+
* import { ScheduleSchema } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
|
|
35
|
+
*
|
|
36
|
+
* const schedule = await stigmer.schedule.getByReference({ org, slug });
|
|
37
|
+
* const updated = clone(ScheduleSchema, schedule);
|
|
38
|
+
* updated.spec!.enabled = false;
|
|
39
|
+
* await stigmer.manifest.apply(manifestDocumentForResource(updated));
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function manifestDocumentForResource(message: Message): ManifestDocument {
|
|
43
|
+
const handler = manifestHandlerForTypeName(message.$typeName);
|
|
44
|
+
if (handler === undefined) {
|
|
45
|
+
const supported = manifestKinds()
|
|
46
|
+
.map((h) => h.yamlKind)
|
|
47
|
+
.join(", ");
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Cannot apply ${message.$typeName} as a manifest: kind is not ` +
|
|
50
|
+
`in the manifest registry. Supported kinds: ${supported}.`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const metadata = metadataOf(message);
|
|
55
|
+
const name = metadata?.name ?? "";
|
|
56
|
+
if (name === "") {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Cannot apply this ${handler.displayName}: metadata.name is empty. ` +
|
|
59
|
+
"Pass a resource as returned by the server (get/getByReference).",
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
handler,
|
|
65
|
+
message,
|
|
66
|
+
name,
|
|
67
|
+
slug: metadata?.slug || name,
|
|
68
|
+
org: metadata?.org ?? "",
|
|
69
|
+
};
|
|
70
|
+
}
|
package/src/manifest/index.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type { ManifestKindHandler, ServiceClientFn } from "./registry.js";
|
|
|
14
14
|
export { parseManifest, metadataOf } from "./parse.js";
|
|
15
15
|
export type { ManifestDocument, ParseManifestOptions } from "./parse.js";
|
|
16
16
|
|
|
17
|
+
export { manifestDocumentForResource } from "./document.js";
|
|
18
|
+
|
|
17
19
|
export { serializeManifest } from "./serialize.js";
|
|
18
20
|
|
|
19
21
|
export { ManifestClient } from "./client.js";
|