@catamorphic/fastify-plugin 0.1.0-alpha.37 → 0.1.0-alpha.38
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/dist/index.js +1040 -827
- package/dist/index.js.map +8 -7
- package/dist/plugin.d.ts.map +1 -1
- package/dist/routes/private-customizations.d.ts +4 -0
- package/dist/routes/private-customizations.d.ts.map +1 -0
- package/dist/routes/session-artifacts.d.ts +5 -0
- package/dist/routes/session-artifacts.d.ts.map +1 -1
- package/dist/routes/workflow-enablements.d.ts +2 -1
- package/dist/routes/workflow-enablements.d.ts.map +1 -1
- package/dist/schemas.d.ts +6 -0
- package/dist/schemas.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/plugin.ts +2 -0
- package/src/routes/private-customizations.ts +287 -0
- package/src/routes/session-artifacts.ts +2 -0
- package/src/routes/workflow-enablements.ts +1 -1
- package/src/schemas.ts +5 -1
package/dist/index.js
CHANGED
|
@@ -1032,7 +1032,7 @@ var SandboxSchema = z.object({
|
|
|
1032
1032
|
provider: z.string(),
|
|
1033
1033
|
providerId: z.string(),
|
|
1034
1034
|
sandboxType: z.enum(["execution", "dev"]),
|
|
1035
|
-
commitSha: z.string().
|
|
1035
|
+
commitSha: z.string().nullable(),
|
|
1036
1036
|
userId: z.string().uuid().nullable(),
|
|
1037
1037
|
status: z.string(),
|
|
1038
1038
|
snapshotName: z.string().nullable(),
|
|
@@ -1069,7 +1069,8 @@ var AgentSessionSourceSchema = z.enum([
|
|
|
1069
1069
|
var AgentSessionsQuerySchema = PaginationQuerySchema.extend({
|
|
1070
1070
|
visibility: z.enum(["promoted", "latent", "archived"]).optional(),
|
|
1071
1071
|
parentSessionId: z.string().uuid().optional(),
|
|
1072
|
-
rootsOnly: z.enum(["true", "false"]).transform((value) => value === "true").optional()
|
|
1072
|
+
rootsOnly: z.enum(["true", "false"]).transform((value) => value === "true").optional(),
|
|
1073
|
+
query: z.string().max(500).optional()
|
|
1073
1074
|
}).refine((value) => !(value.rootsOnly && value.parentSessionId), {
|
|
1074
1075
|
message: "Choose rootsOnly or parentSessionId, not both."
|
|
1075
1076
|
});
|
|
@@ -1151,6 +1152,7 @@ var AgentSessionSchema = z.object({
|
|
|
1151
1152
|
attentionSeenRevision: z.number().int().nonnegative(),
|
|
1152
1153
|
attentionRequired: z.boolean(),
|
|
1153
1154
|
attentionMessage: z.object({ id: z.string().uuid(), content: z.string() }).optional(),
|
|
1155
|
+
match: z.string().optional(),
|
|
1154
1156
|
key: z.string().nullable(),
|
|
1155
1157
|
keyWorkflows: z.array(z.string()),
|
|
1156
1158
|
placement: AgentSessionPlacementSchema.nullable(),
|
|
@@ -6739,213 +6741,958 @@ function registerPluginRoutes(app, ctx) {
|
|
|
6739
6741
|
});
|
|
6740
6742
|
}
|
|
6741
6743
|
|
|
6742
|
-
// src/routes/
|
|
6743
|
-
import { agentCapabilityTools } from "@catamorphic/sandbox";
|
|
6744
|
-
import { z as z17 } from "zod";
|
|
6745
|
-
|
|
6746
|
-
// src/project-mcp-program.ts
|
|
6744
|
+
// src/routes/private-customizations.ts
|
|
6747
6745
|
import {
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6746
|
+
DocumentConflictError as DocumentConflictError2,
|
|
6747
|
+
DocumentNotFoundError as DocumentNotFoundError2,
|
|
6748
|
+
DocumentPathError as DocumentPathError2,
|
|
6749
|
+
PrivateStateDeleteSchema,
|
|
6750
|
+
PrivateStateReadSchema,
|
|
6751
|
+
PrivateStateSchema,
|
|
6752
|
+
PrivateStateWriteSchema,
|
|
6753
|
+
PublishNotificationSchema
|
|
6755
6754
|
} from "@catamorphic/core";
|
|
6756
|
-
import {
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
properties: {
|
|
6808
|
-
path: { type: "string" },
|
|
6809
|
-
content: { type: "string" },
|
|
6810
|
-
delete: { type: "boolean" }
|
|
6811
|
-
},
|
|
6812
|
-
required: ["path"]
|
|
6813
|
-
}
|
|
6814
|
-
}
|
|
6815
|
-
},
|
|
6816
|
-
required: ["changes"]
|
|
6817
|
-
}
|
|
6818
|
-
},
|
|
6819
|
-
call: guarded(async (args) => {
|
|
6820
|
-
const changes = Array.isArray(args.changes) ? args.changes : [];
|
|
6821
|
-
if (changes.length === 0)
|
|
6822
|
-
throw new Error("changes is required");
|
|
6823
|
-
await refreshDraft(core, identity, projectId);
|
|
6824
|
-
const draftChanges = changes.map((raw) => {
|
|
6825
|
-
const change = asRecord(raw);
|
|
6826
|
-
const path = str(change.path);
|
|
6827
|
-
if (!path)
|
|
6828
|
-
throw new Error("Each change needs a path");
|
|
6829
|
-
if (change.delete === true)
|
|
6830
|
-
return { path, delete: true };
|
|
6831
|
-
const content = str(change.content);
|
|
6832
|
-
if (content === undefined)
|
|
6833
|
-
throw new Error(`${path}: pass content or delete: true`);
|
|
6834
|
-
return { path, content };
|
|
6835
|
-
});
|
|
6836
|
-
await core.projects.writeFiles({
|
|
6837
|
-
identity,
|
|
6838
|
-
projectId,
|
|
6839
|
-
changes: draftChanges
|
|
6840
|
-
});
|
|
6841
|
-
return { written: draftChanges.map((change) => change.path) };
|
|
6842
|
-
})
|
|
6843
|
-
}, {
|
|
6844
|
-
definition: {
|
|
6845
|
-
name: "program_check",
|
|
6846
|
-
description: "Refresh your draft's generated types (the trigger kinds this server offers, in .work/workflows/src/work-triggers.d.ts, and each app's workflow API types), then validate it the way publishing does: workflow and app parse errors and trigger configurations. Run it after writing and before program_deploy.",
|
|
6847
|
-
inputSchema: { type: "object", properties: {} }
|
|
6848
|
-
},
|
|
6849
|
-
call: guarded(async () => checkDraft(core, identity, projectId))
|
|
6850
|
-
});
|
|
6851
|
-
}
|
|
6852
|
-
if (may("program:write") && may("program:publish")) {
|
|
6853
|
-
tools.push({
|
|
6854
|
-
definition: {
|
|
6855
|
-
name: "program_deploy",
|
|
6856
|
-
description: "Publish your draft as the project's production program: workflows move to it, and every app it changes (or that was never published) is built and published, with each app's result reported. Refused while program_check reports errors, and for projects whose program lives in a linked repository (use propose_change there).",
|
|
6857
|
-
inputSchema: {
|
|
6858
|
-
type: "object",
|
|
6859
|
-
properties: {
|
|
6860
|
-
message: {
|
|
6861
|
-
type: "string",
|
|
6862
|
-
description: "What changed and why, as a commit message"
|
|
6863
|
-
}
|
|
6864
|
-
},
|
|
6865
|
-
required: ["message"]
|
|
6866
|
-
}
|
|
6867
|
-
},
|
|
6868
|
-
call: guarded(async (args) => {
|
|
6869
|
-
const message = str(args.message);
|
|
6870
|
-
if (!message)
|
|
6871
|
-
throw new Error("message is required");
|
|
6872
|
-
const project = await core.projects.get(identity, projectId);
|
|
6873
|
-
if (project.remoteUrl)
|
|
6874
|
-
throw new Error(`This project's program is published from ${project.remoteUrl}. Open a pull request there, or use propose_change.`);
|
|
6875
|
-
const check = await checkDraft(core, identity, projectId);
|
|
6876
|
-
if (!check.ok)
|
|
6877
|
-
return { status: "blocked", ...check };
|
|
6878
|
-
const before = await core.deployment.getStatus(identity.tenantId, projectId, identity.externalUserId);
|
|
6879
|
-
const result = await core.deployment.deploy(identity.tenantId, projectId, identity.externalUserId, {
|
|
6880
|
-
message,
|
|
6881
|
-
guardPublishedPaths: (paths) => assertMayManageRolePolicy(identity, projectId, paths)
|
|
6882
|
-
});
|
|
6883
|
-
const published = result.status === "deployed" ? result.commitSha : result.status === "nothing-to-deploy" ? before.remoteHead : null;
|
|
6884
|
-
const apps = published ? await publishApps({
|
|
6885
|
-
core,
|
|
6886
|
-
identity,
|
|
6887
|
-
projectId,
|
|
6888
|
-
base: result.status === "deployed" ? before.remoteHead : published,
|
|
6889
|
-
head: published
|
|
6890
|
-
}) : [];
|
|
6891
|
-
return { ...result, apps, warnings: check.findings };
|
|
6892
|
-
})
|
|
6893
|
-
});
|
|
6894
|
-
}
|
|
6895
|
-
tools.push({
|
|
6896
|
-
definition: {
|
|
6897
|
-
name: "workflow_run",
|
|
6898
|
-
description: "Run a deployed workflow with an input. Waits up to 30 seconds: a finished run returns its output, a longer one returns its runId for run_details. Pass environment to choose where it runs (names in project_overview).",
|
|
6899
|
-
inputSchema: {
|
|
6900
|
-
type: "object",
|
|
6901
|
-
properties: {
|
|
6902
|
-
workflow: { type: "string" },
|
|
6903
|
-
input: {
|
|
6904
|
-
description: "The workflow's input, as JSON of the workflow's input type",
|
|
6905
|
-
type: ["object", "array", "string", "number", "boolean", "null"]
|
|
6906
|
-
},
|
|
6907
|
-
environment: { type: "string" }
|
|
6908
|
-
},
|
|
6909
|
-
required: ["workflow"]
|
|
6755
|
+
import { z as z16 } from "zod";
|
|
6756
|
+
|
|
6757
|
+
// src/routes/session-artifacts.ts
|
|
6758
|
+
import { APP_ICON_NAMES as APP_ICON_NAMES3 } from "@catamorphic/app";
|
|
6759
|
+
import { SessionArtifactNotFoundError } from "@catamorphic/core";
|
|
6760
|
+
import { z as z14 } from "zod";
|
|
6761
|
+
var SessionArtifactSchema = z14.object({
|
|
6762
|
+
id: z14.string().uuid(),
|
|
6763
|
+
projectId: z14.string().uuid(),
|
|
6764
|
+
sessionId: z14.string().uuid().nullable(),
|
|
6765
|
+
lifetime: z14.enum(["session", "member"]),
|
|
6766
|
+
workflowEnablementId: z14.string().uuid().nullable(),
|
|
6767
|
+
kind: z14.enum(["app", "workflow"]),
|
|
6768
|
+
name: z14.string(),
|
|
6769
|
+
title: z14.string(),
|
|
6770
|
+
sourcePath: z14.string(),
|
|
6771
|
+
remoteBranch: z14.string(),
|
|
6772
|
+
commitSha: z14.string(),
|
|
6773
|
+
revision: z14.number().int(),
|
|
6774
|
+
status: z14.enum(["active", "discarded"]),
|
|
6775
|
+
appName: z14.string().nullable(),
|
|
6776
|
+
createdAt: z14.string(),
|
|
6777
|
+
updatedAt: z14.string()
|
|
6778
|
+
});
|
|
6779
|
+
var SessionParams = z14.object({
|
|
6780
|
+
projectId: z14.string().uuid(),
|
|
6781
|
+
sessionId: z14.string().uuid()
|
|
6782
|
+
});
|
|
6783
|
+
var ArtifactParams = z14.object({
|
|
6784
|
+
projectId: z14.string().uuid(),
|
|
6785
|
+
artifactId: z14.string().uuid()
|
|
6786
|
+
});
|
|
6787
|
+
var Files = z14.record(z14.string().min(1).max(512), z14.string()).refine((files) => Object.keys(files).length <= 256);
|
|
6788
|
+
var Outcome = z14.object({
|
|
6789
|
+
artifact: SessionArtifactSchema,
|
|
6790
|
+
build: AppVersionSchema.nullable()
|
|
6791
|
+
});
|
|
6792
|
+
function registerSessionArtifactRoutes(app, ctx) {
|
|
6793
|
+
const typed = app.withTypeProvider();
|
|
6794
|
+
typed.route({
|
|
6795
|
+
method: "GET",
|
|
6796
|
+
url: "/projects/:projectId/agent/sessions/:sessionId/artifacts",
|
|
6797
|
+
schema: {
|
|
6798
|
+
params: SessionParams,
|
|
6799
|
+
response: {
|
|
6800
|
+
200: z14.array(SessionArtifactSchema),
|
|
6801
|
+
400: ErrorSchema,
|
|
6802
|
+
403: ErrorSchema,
|
|
6803
|
+
404: ErrorSchema,
|
|
6804
|
+
409: ErrorSchema,
|
|
6805
|
+
503: ErrorSchema
|
|
6910
6806
|
}
|
|
6911
6807
|
},
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
identity,
|
|
6919
|
-
projectId,
|
|
6920
|
-
workflowName,
|
|
6921
|
-
...environment ? { environment } : {},
|
|
6922
|
-
...args.input === undefined ? {} : { input: args.input },
|
|
6923
|
-
budgetMs: TOOL_SYNC_BUDGET_MS
|
|
6808
|
+
handler: async (request, reply) => {
|
|
6809
|
+
if (!ctx.core)
|
|
6810
|
+
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
6811
|
+
return ctx.core.sessionArtifacts.list({
|
|
6812
|
+
...request.params,
|
|
6813
|
+
identity: resolveIdentity(request)
|
|
6924
6814
|
});
|
|
6925
|
-
}
|
|
6926
|
-
}
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6815
|
+
}
|
|
6816
|
+
});
|
|
6817
|
+
typed.route({
|
|
6818
|
+
method: "POST",
|
|
6819
|
+
url: "/projects/:projectId/agent/sessions/:sessionId/artifacts",
|
|
6820
|
+
bodyLimit: 6 * 1024 * 1024,
|
|
6821
|
+
schema: {
|
|
6822
|
+
params: SessionParams,
|
|
6823
|
+
body: z14.object({
|
|
6824
|
+
kind: z14.enum(["app", "workflow"]),
|
|
6825
|
+
name: z14.string().min(1).max(100),
|
|
6826
|
+
title: z14.string().max(200).optional(),
|
|
6827
|
+
icon: z14.enum(APP_ICON_NAMES3).optional(),
|
|
6828
|
+
source: z14.string().max(5 * 1024 * 1024),
|
|
6829
|
+
files: Files.optional()
|
|
6830
|
+
}),
|
|
6831
|
+
response: {
|
|
6832
|
+
201: Outcome,
|
|
6833
|
+
400: ErrorSchema,
|
|
6834
|
+
403: ErrorSchema,
|
|
6835
|
+
404: ErrorSchema,
|
|
6836
|
+
409: ErrorSchema,
|
|
6837
|
+
503: ErrorSchema
|
|
6838
|
+
}
|
|
6938
6839
|
},
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
...
|
|
6945
|
-
|
|
6840
|
+
handler: async (request, reply) => {
|
|
6841
|
+
if (!ctx.core || request.body.kind === "app" && !ctx.core.apps)
|
|
6842
|
+
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
6843
|
+
const identity = resolveIdentity(request);
|
|
6844
|
+
const artifact = await ctx.core.sessionArtifacts.create({
|
|
6845
|
+
...request.params,
|
|
6846
|
+
...request.body,
|
|
6847
|
+
identity
|
|
6946
6848
|
});
|
|
6947
|
-
|
|
6948
|
-
|
|
6849
|
+
const build = artifact.appName && ctx.core.apps ? await ctx.core.apps.build({
|
|
6850
|
+
identity,
|
|
6851
|
+
projectId: artifact.projectId,
|
|
6852
|
+
appName: artifact.appName,
|
|
6853
|
+
artifactId: artifact.id,
|
|
6854
|
+
kind: "preview"
|
|
6855
|
+
}) : null;
|
|
6856
|
+
if (artifact.appName && request.body.icon && ctx.core.apps)
|
|
6857
|
+
await ctx.core.apps.updatePresentation({
|
|
6858
|
+
identity,
|
|
6859
|
+
projectId: artifact.projectId,
|
|
6860
|
+
appName: artifact.appName,
|
|
6861
|
+
icon: request.body.icon
|
|
6862
|
+
});
|
|
6863
|
+
return reply.status(201).send({ artifact, build });
|
|
6864
|
+
}
|
|
6865
|
+
});
|
|
6866
|
+
typed.route({
|
|
6867
|
+
method: "GET",
|
|
6868
|
+
url: "/projects/:projectId/session-artifacts/:artifactId",
|
|
6869
|
+
schema: {
|
|
6870
|
+
params: ArtifactParams,
|
|
6871
|
+
response: {
|
|
6872
|
+
200: SessionArtifactSchema,
|
|
6873
|
+
400: ErrorSchema,
|
|
6874
|
+
403: ErrorSchema,
|
|
6875
|
+
404: ErrorSchema,
|
|
6876
|
+
409: ErrorSchema,
|
|
6877
|
+
503: ErrorSchema
|
|
6878
|
+
}
|
|
6879
|
+
},
|
|
6880
|
+
handler: async (request, reply) => {
|
|
6881
|
+
if (!ctx.core)
|
|
6882
|
+
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
6883
|
+
try {
|
|
6884
|
+
return await ctx.core.sessionArtifacts.get({
|
|
6885
|
+
...request.params,
|
|
6886
|
+
identity: resolveIdentity(request)
|
|
6887
|
+
});
|
|
6888
|
+
} catch (error) {
|
|
6889
|
+
if (error instanceof SessionArtifactNotFoundError)
|
|
6890
|
+
return reply.status(404).send({ error: error.message });
|
|
6891
|
+
throw error;
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6894
|
+
});
|
|
6895
|
+
typed.route({
|
|
6896
|
+
method: "GET",
|
|
6897
|
+
url: "/projects/:projectId/session-artifacts/:artifactId/files",
|
|
6898
|
+
schema: {
|
|
6899
|
+
params: ArtifactParams,
|
|
6900
|
+
response: {
|
|
6901
|
+
200: z14.record(z14.string(), z14.string()),
|
|
6902
|
+
400: ErrorSchema,
|
|
6903
|
+
403: ErrorSchema,
|
|
6904
|
+
404: ErrorSchema,
|
|
6905
|
+
409: ErrorSchema,
|
|
6906
|
+
503: ErrorSchema
|
|
6907
|
+
}
|
|
6908
|
+
},
|
|
6909
|
+
handler: async (request, reply) => {
|
|
6910
|
+
if (!ctx.core)
|
|
6911
|
+
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
6912
|
+
return ctx.core.sessionArtifacts.files({
|
|
6913
|
+
...request.params,
|
|
6914
|
+
identity: resolveIdentity(request)
|
|
6915
|
+
});
|
|
6916
|
+
}
|
|
6917
|
+
});
|
|
6918
|
+
typed.route({
|
|
6919
|
+
method: "PATCH",
|
|
6920
|
+
url: "/projects/:projectId/session-artifacts/:artifactId",
|
|
6921
|
+
bodyLimit: 6 * 1024 * 1024,
|
|
6922
|
+
schema: {
|
|
6923
|
+
params: ArtifactParams,
|
|
6924
|
+
body: z14.object({
|
|
6925
|
+
revision: z14.number().int().positive(),
|
|
6926
|
+
title: z14.string().max(200).optional(),
|
|
6927
|
+
files: z14.record(z14.string().min(1).max(512), z14.string().nullable())
|
|
6928
|
+
}),
|
|
6929
|
+
response: {
|
|
6930
|
+
200: Outcome,
|
|
6931
|
+
400: ErrorSchema,
|
|
6932
|
+
403: ErrorSchema,
|
|
6933
|
+
404: ErrorSchema,
|
|
6934
|
+
409: ErrorSchema,
|
|
6935
|
+
503: ErrorSchema
|
|
6936
|
+
}
|
|
6937
|
+
},
|
|
6938
|
+
handler: async (request, reply) => {
|
|
6939
|
+
if (!ctx.core)
|
|
6940
|
+
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
6941
|
+
const identity = resolveIdentity(request);
|
|
6942
|
+
const artifact = await ctx.core.sessionArtifacts.update({
|
|
6943
|
+
...request.params,
|
|
6944
|
+
...request.body,
|
|
6945
|
+
identity
|
|
6946
|
+
});
|
|
6947
|
+
const build = artifact.appName && ctx.core.apps ? await ctx.core.apps.build({
|
|
6948
|
+
identity,
|
|
6949
|
+
projectId: artifact.projectId,
|
|
6950
|
+
appName: artifact.appName,
|
|
6951
|
+
artifactId: artifact.id,
|
|
6952
|
+
kind: "preview"
|
|
6953
|
+
}) : null;
|
|
6954
|
+
return { artifact, build };
|
|
6955
|
+
}
|
|
6956
|
+
});
|
|
6957
|
+
typed.route({
|
|
6958
|
+
method: "DELETE",
|
|
6959
|
+
url: "/projects/:projectId/session-artifacts/:artifactId",
|
|
6960
|
+
schema: {
|
|
6961
|
+
params: ArtifactParams,
|
|
6962
|
+
response: {
|
|
6963
|
+
204: z14.null(),
|
|
6964
|
+
400: ErrorSchema,
|
|
6965
|
+
403: ErrorSchema,
|
|
6966
|
+
404: ErrorSchema,
|
|
6967
|
+
409: ErrorSchema,
|
|
6968
|
+
503: ErrorSchema
|
|
6969
|
+
}
|
|
6970
|
+
},
|
|
6971
|
+
handler: async (request, reply) => {
|
|
6972
|
+
if (!ctx.core)
|
|
6973
|
+
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
6974
|
+
const identity = resolveIdentity(request);
|
|
6975
|
+
const artifact = await ctx.core.sessionArtifacts.discard({
|
|
6976
|
+
...request.params,
|
|
6977
|
+
identity
|
|
6978
|
+
});
|
|
6979
|
+
if (artifact.sessionId && ctx.core.watchers)
|
|
6980
|
+
await ctx.core.watchers.stop({
|
|
6981
|
+
identity,
|
|
6982
|
+
projectId: artifact.projectId,
|
|
6983
|
+
sessionId: artifact.sessionId,
|
|
6984
|
+
watcherId: artifact.id
|
|
6985
|
+
});
|
|
6986
|
+
return reply.status(204).send(null);
|
|
6987
|
+
}
|
|
6988
|
+
});
|
|
6989
|
+
typed.route({
|
|
6990
|
+
method: "POST",
|
|
6991
|
+
url: "/projects/:projectId/session-artifacts/:artifactId/runs",
|
|
6992
|
+
schema: {
|
|
6993
|
+
params: ArtifactParams,
|
|
6994
|
+
body: TriggerRunSchema.extend({ environment: z14.string().optional() }),
|
|
6995
|
+
response: {
|
|
6996
|
+
201: RunSchema,
|
|
6997
|
+
400: ErrorSchema,
|
|
6998
|
+
403: ErrorSchema,
|
|
6999
|
+
404: ErrorSchema,
|
|
7000
|
+
409: ErrorSchema,
|
|
7001
|
+
503: ErrorSchema
|
|
7002
|
+
}
|
|
7003
|
+
},
|
|
7004
|
+
handler: async (request, reply) => {
|
|
7005
|
+
if (!ctx.core)
|
|
7006
|
+
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
7007
|
+
const identity = resolveIdentity(request);
|
|
7008
|
+
const artifact = await ctx.core.sessionArtifacts.get({
|
|
7009
|
+
...request.params,
|
|
7010
|
+
identity
|
|
7011
|
+
});
|
|
7012
|
+
if (artifact.kind !== "workflow")
|
|
7013
|
+
return reply.status(400).send({ error: "This artifact is an app" });
|
|
7014
|
+
await ctx.core.sessionArtifacts.assertActive({
|
|
7015
|
+
...request.params,
|
|
7016
|
+
identity
|
|
7017
|
+
});
|
|
7018
|
+
const run = await ctx.core.runs.triggerAtCommit({
|
|
7019
|
+
...request.body,
|
|
7020
|
+
identity,
|
|
7021
|
+
projectId: artifact.projectId,
|
|
7022
|
+
workflowName: artifact.name,
|
|
7023
|
+
commitSha: artifact.commitSha,
|
|
7024
|
+
remoteBranch: artifact.remoteBranch
|
|
7025
|
+
});
|
|
7026
|
+
return reply.status(201).send(run);
|
|
7027
|
+
}
|
|
7028
|
+
});
|
|
7029
|
+
}
|
|
7030
|
+
|
|
7031
|
+
// src/routes/workflow-enablements.ts
|
|
7032
|
+
import {
|
|
7033
|
+
AccessDeniedError as AccessDeniedError7,
|
|
7034
|
+
AuthenticationRequiredError as AuthenticationRequiredError4,
|
|
7035
|
+
ConnectionPermissionDeniedError as ConnectionPermissionDeniedError3,
|
|
7036
|
+
ConnectionUnavailableError as ConnectionUnavailableError3,
|
|
7037
|
+
EnvironmentAccessDeniedError as EnvironmentAccessDeniedError4,
|
|
7038
|
+
EnvironmentBindingUnavailableError as EnvironmentBindingUnavailableError4,
|
|
7039
|
+
EnvironmentIncompatibleError as EnvironmentIncompatibleError4,
|
|
7040
|
+
EnvironmentNotFoundError as EnvironmentNotFoundError4,
|
|
7041
|
+
EnvironmentPolicyInvalidError,
|
|
7042
|
+
ProductionDeploymentNotFoundError as ProductionDeploymentNotFoundError3,
|
|
7043
|
+
WorkflowEnablementConflictError,
|
|
7044
|
+
WorkflowEnablementConsentRequiredError,
|
|
7045
|
+
WorkflowEnablementNotFoundError,
|
|
7046
|
+
WorkflowEnablementSuspendedError,
|
|
7047
|
+
WorkflowNotFoundError as WorkflowNotFoundError2
|
|
7048
|
+
} from "@catamorphic/core";
|
|
7049
|
+
import { z as z15 } from "zod";
|
|
7050
|
+
var EnablementParamsSchema = ProjectIdParamsSchema.extend({
|
|
7051
|
+
enablementId: z15.string().uuid()
|
|
7052
|
+
});
|
|
7053
|
+
var NotPublishedErrorSchema = z15.object({
|
|
7054
|
+
error: z15.string(),
|
|
7055
|
+
reason: z15.literal("not_published")
|
|
7056
|
+
});
|
|
7057
|
+
var PreviewConflictSchema = z15.union([NotPublishedErrorSchema, ErrorSchema]);
|
|
7058
|
+
var SelectionSchema = z15.record(z15.string(), z15.string().uuid()).optional();
|
|
7059
|
+
var PreviewBodySchema = z15.object({
|
|
7060
|
+
workflowName: z15.string().min(1),
|
|
7061
|
+
environment: z15.string().min(1).optional(),
|
|
7062
|
+
owner: WorkflowEnablementOwnerSchema.optional(),
|
|
7063
|
+
connectionSelections: SelectionSchema
|
|
7064
|
+
});
|
|
7065
|
+
function registerWorkflowEnablementRoutes(app, ctx) {
|
|
7066
|
+
const typed = app.withTypeProvider();
|
|
7067
|
+
const service = () => ctx.core?.workflowEnablements;
|
|
7068
|
+
typed.route({
|
|
7069
|
+
method: "GET",
|
|
7070
|
+
url: "/projects/:projectId/workflow-enablements",
|
|
7071
|
+
schema: {
|
|
7072
|
+
params: ProjectIdParamsSchema,
|
|
7073
|
+
querystring: z15.object({ workflowName: z15.string().optional() }),
|
|
7074
|
+
response: {
|
|
7075
|
+
200: z15.object({
|
|
7076
|
+
items: z15.array(WorkflowEnablementSchema),
|
|
7077
|
+
canManageProjectAutomations: z15.boolean()
|
|
7078
|
+
}),
|
|
7079
|
+
503: ErrorSchema
|
|
7080
|
+
}
|
|
7081
|
+
},
|
|
7082
|
+
handler: async (request, reply) => {
|
|
7083
|
+
const workflowEnablements = service();
|
|
7084
|
+
if (!workflowEnablements) {
|
|
7085
|
+
return reply.status(503).send({ error: "Workflow enablements unavailable" });
|
|
7086
|
+
}
|
|
7087
|
+
const identity = resolveIdentity(request);
|
|
7088
|
+
const { projectId } = request.params;
|
|
7089
|
+
return reply.send({
|
|
7090
|
+
items: await workflowEnablements.list({
|
|
7091
|
+
identity,
|
|
7092
|
+
projectId,
|
|
7093
|
+
workflowName: request.query.workflowName
|
|
7094
|
+
}),
|
|
7095
|
+
canManageProjectAutomations: workflowEnablements.mayManageProjectAutomations({
|
|
7096
|
+
identity,
|
|
7097
|
+
projectId
|
|
7098
|
+
})
|
|
7099
|
+
});
|
|
7100
|
+
}
|
|
7101
|
+
});
|
|
7102
|
+
typed.route({
|
|
7103
|
+
method: "POST",
|
|
7104
|
+
url: "/projects/:projectId/workflow-enablement-preview",
|
|
7105
|
+
schema: {
|
|
7106
|
+
params: ProjectIdParamsSchema,
|
|
7107
|
+
body: PreviewBodySchema,
|
|
7108
|
+
response: {
|
|
7109
|
+
200: WorkflowEnablementPreviewSchema,
|
|
7110
|
+
403: ErrorSchema,
|
|
7111
|
+
409: PreviewConflictSchema,
|
|
7112
|
+
428: AuthenticationRequiredSchema,
|
|
7113
|
+
503: ErrorSchema
|
|
7114
|
+
}
|
|
7115
|
+
},
|
|
7116
|
+
handler: async (request, reply) => {
|
|
7117
|
+
const workflowEnablements = service();
|
|
7118
|
+
if (!workflowEnablements) {
|
|
7119
|
+
return reply.status(503).send({ error: "Workflow enablements unavailable" });
|
|
7120
|
+
}
|
|
7121
|
+
try {
|
|
7122
|
+
return reply.send(await workflowEnablements.preview({
|
|
7123
|
+
identity: resolveIdentity(request),
|
|
7124
|
+
projectId: request.params.projectId,
|
|
7125
|
+
...request.body
|
|
7126
|
+
}));
|
|
7127
|
+
} catch (error) {
|
|
7128
|
+
return handleEnablementError(error, reply);
|
|
7129
|
+
}
|
|
7130
|
+
}
|
|
7131
|
+
});
|
|
7132
|
+
typed.route({
|
|
7133
|
+
method: "POST",
|
|
7134
|
+
url: "/projects/:projectId/workflow-enablements",
|
|
7135
|
+
schema: {
|
|
7136
|
+
params: ProjectIdParamsSchema,
|
|
7137
|
+
body: PreviewBodySchema.extend({ consentDigest: z15.string().length(64) }),
|
|
7138
|
+
response: {
|
|
7139
|
+
201: WorkflowEnablementSchema,
|
|
7140
|
+
403: ErrorSchema,
|
|
7141
|
+
409: PreviewConflictSchema,
|
|
7142
|
+
428: AuthenticationRequiredSchema,
|
|
7143
|
+
503: ErrorSchema
|
|
7144
|
+
}
|
|
7145
|
+
},
|
|
7146
|
+
handler: async (request, reply) => {
|
|
7147
|
+
const workflowEnablements = service();
|
|
7148
|
+
if (!workflowEnablements) {
|
|
7149
|
+
return reply.status(503).send({ error: "Workflow enablements unavailable" });
|
|
7150
|
+
}
|
|
7151
|
+
try {
|
|
7152
|
+
return reply.status(201).send(await workflowEnablements.create({
|
|
7153
|
+
identity: resolveIdentity(request),
|
|
7154
|
+
projectId: request.params.projectId,
|
|
7155
|
+
...request.body
|
|
7156
|
+
}));
|
|
7157
|
+
} catch (error) {
|
|
7158
|
+
return handleEnablementError(error, reply);
|
|
7159
|
+
}
|
|
7160
|
+
}
|
|
7161
|
+
});
|
|
7162
|
+
typed.route({
|
|
7163
|
+
method: "GET",
|
|
7164
|
+
url: "/projects/:projectId/workflow-enablements/:enablementId",
|
|
7165
|
+
schema: {
|
|
7166
|
+
params: EnablementParamsSchema,
|
|
7167
|
+
response: {
|
|
7168
|
+
200: WorkflowEnablementSchema,
|
|
7169
|
+
403: ErrorSchema,
|
|
7170
|
+
404: ErrorSchema
|
|
7171
|
+
}
|
|
7172
|
+
},
|
|
7173
|
+
handler: async (request, reply) => {
|
|
7174
|
+
const workflowEnablements = service();
|
|
7175
|
+
if (!workflowEnablements) {
|
|
7176
|
+
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
7177
|
+
}
|
|
7178
|
+
try {
|
|
7179
|
+
const result = await workflowEnablements.get({
|
|
7180
|
+
identity: resolveIdentity(request),
|
|
7181
|
+
enablementId: request.params.enablementId
|
|
7182
|
+
});
|
|
7183
|
+
return result.projectId === request.params.projectId ? reply.send(result) : reply.status(404).send({ error: "Workflow enablement not found" });
|
|
7184
|
+
} catch (error) {
|
|
7185
|
+
return handleEnablementError(error, reply);
|
|
7186
|
+
}
|
|
7187
|
+
}
|
|
7188
|
+
});
|
|
7189
|
+
for (const action of ["disable", "reenable"]) {
|
|
7190
|
+
typed.route({
|
|
7191
|
+
method: "POST",
|
|
7192
|
+
url: `/projects/:projectId/workflow-enablements/:enablementId/${action}`,
|
|
7193
|
+
schema: {
|
|
7194
|
+
params: EnablementParamsSchema,
|
|
7195
|
+
response: {
|
|
7196
|
+
200: WorkflowEnablementSchema,
|
|
7197
|
+
403: ErrorSchema,
|
|
7198
|
+
404: ErrorSchema,
|
|
7199
|
+
409: PreviewConflictSchema
|
|
7200
|
+
}
|
|
7201
|
+
},
|
|
7202
|
+
handler: async (request, reply) => {
|
|
7203
|
+
const workflowEnablements = service();
|
|
7204
|
+
if (!workflowEnablements) {
|
|
7205
|
+
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
7206
|
+
}
|
|
7207
|
+
try {
|
|
7208
|
+
const identity = resolveIdentity(request);
|
|
7209
|
+
const current = await workflowEnablements.get({
|
|
7210
|
+
identity,
|
|
7211
|
+
enablementId: request.params.enablementId
|
|
7212
|
+
});
|
|
7213
|
+
if (current.projectId !== request.params.projectId) {
|
|
7214
|
+
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
7215
|
+
}
|
|
7216
|
+
const result = await workflowEnablements[action]({
|
|
7217
|
+
identity,
|
|
7218
|
+
enablementId: request.params.enablementId
|
|
7219
|
+
});
|
|
7220
|
+
return reply.send(result);
|
|
7221
|
+
} catch (error) {
|
|
7222
|
+
return handleEnablementError(error, reply);
|
|
7223
|
+
}
|
|
7224
|
+
}
|
|
7225
|
+
});
|
|
7226
|
+
}
|
|
7227
|
+
typed.route({
|
|
7228
|
+
method: "POST",
|
|
7229
|
+
url: "/projects/:projectId/workflow-enablements/:enablementId/update-deployment",
|
|
7230
|
+
schema: {
|
|
7231
|
+
params: EnablementParamsSchema,
|
|
7232
|
+
body: z15.object({ consentDigest: z15.string().length(64) }),
|
|
7233
|
+
response: {
|
|
7234
|
+
200: WorkflowEnablementSchema,
|
|
7235
|
+
403: ErrorSchema,
|
|
7236
|
+
404: ErrorSchema,
|
|
7237
|
+
409: PreviewConflictSchema,
|
|
7238
|
+
428: AuthenticationRequiredSchema
|
|
7239
|
+
}
|
|
7240
|
+
},
|
|
7241
|
+
handler: async (request, reply) => {
|
|
7242
|
+
const workflowEnablements = service();
|
|
7243
|
+
if (!workflowEnablements) {
|
|
7244
|
+
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
7245
|
+
}
|
|
7246
|
+
try {
|
|
7247
|
+
const identity = resolveIdentity(request);
|
|
7248
|
+
const current = await workflowEnablements.get({
|
|
7249
|
+
identity,
|
|
7250
|
+
enablementId: request.params.enablementId
|
|
7251
|
+
});
|
|
7252
|
+
if (current.projectId !== request.params.projectId) {
|
|
7253
|
+
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
7254
|
+
}
|
|
7255
|
+
const result = await workflowEnablements.updateDeployment({
|
|
7256
|
+
identity,
|
|
7257
|
+
enablementId: request.params.enablementId,
|
|
7258
|
+
consentDigest: request.body.consentDigest
|
|
7259
|
+
});
|
|
7260
|
+
return reply.send(result);
|
|
7261
|
+
} catch (error) {
|
|
7262
|
+
return handleEnablementError(error, reply);
|
|
7263
|
+
}
|
|
7264
|
+
}
|
|
7265
|
+
});
|
|
7266
|
+
}
|
|
7267
|
+
function handleEnablementError(error, reply) {
|
|
7268
|
+
if (error instanceof AuthenticationRequiredError4) {
|
|
7269
|
+
return reply.status(428).send({
|
|
7270
|
+
error: error.message,
|
|
7271
|
+
code: "authentication_required",
|
|
7272
|
+
environment: error.environment,
|
|
7273
|
+
requirements: error.requirements
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7276
|
+
if (error instanceof WorkflowEnablementNotFoundError) {
|
|
7277
|
+
return reply.status(404).send({ error: error.message });
|
|
7278
|
+
}
|
|
7279
|
+
if (error instanceof WorkflowNotFoundError2 || error instanceof ProductionDeploymentNotFoundError3) {
|
|
7280
|
+
return reply.status(409).send({
|
|
7281
|
+
error: "This workflow isn't in the project's published version yet. Publish the project's changes, then turn it on.",
|
|
7282
|
+
reason: "not_published"
|
|
7283
|
+
});
|
|
7284
|
+
}
|
|
7285
|
+
if (error instanceof AccessDeniedError7 || error instanceof ConnectionPermissionDeniedError3 || error instanceof EnvironmentAccessDeniedError4) {
|
|
7286
|
+
return reply.status(403).send({ error: error.message });
|
|
7287
|
+
}
|
|
7288
|
+
if (error instanceof WorkflowEnablementConsentRequiredError || error instanceof WorkflowEnablementConflictError || error instanceof ConnectionUnavailableError3 || error instanceof EnvironmentNotFoundError4 || error instanceof EnvironmentPolicyInvalidError || error instanceof EnvironmentIncompatibleError4 || error instanceof EnvironmentBindingUnavailableError4 || error instanceof WorkflowEnablementSuspendedError) {
|
|
7289
|
+
return reply.status(409).send({ error: error.message });
|
|
7290
|
+
}
|
|
7291
|
+
throw error;
|
|
7292
|
+
}
|
|
7293
|
+
|
|
7294
|
+
// src/routes/private-customizations.ts
|
|
7295
|
+
var State = PrivateStateSchema.extend({ value: JsonValueSchema });
|
|
7296
|
+
var StateWrite = PrivateStateWriteSchema.extend({ value: JsonValueSchema });
|
|
7297
|
+
var Project = z16.object({ projectId: z16.string().uuid() });
|
|
7298
|
+
var Artifact = Project.extend({ artifactId: z16.string().uuid() });
|
|
7299
|
+
var Revision = z16.object({
|
|
7300
|
+
revision: z16.number().int().positive(),
|
|
7301
|
+
environment: z16.string().optional()
|
|
7302
|
+
});
|
|
7303
|
+
var errors = {
|
|
7304
|
+
400: ErrorSchema,
|
|
7305
|
+
403: ErrorSchema,
|
|
7306
|
+
404: ErrorSchema,
|
|
7307
|
+
409: ErrorSchema.extend({ currentVersion: z16.number().optional() }),
|
|
7308
|
+
422: ErrorSchema,
|
|
7309
|
+
428: AuthenticationRequiredSchema,
|
|
7310
|
+
429: ErrorSchema,
|
|
7311
|
+
503: ErrorSchema
|
|
7312
|
+
};
|
|
7313
|
+
function registerPrivateCustomizationRoutes(app, ctx) {
|
|
7314
|
+
app.register(async (privateApp) => {
|
|
7315
|
+
privateApp.setErrorHandler((error, _request, reply) => {
|
|
7316
|
+
if (error instanceof DocumentConflictError2)
|
|
7317
|
+
return reply.status(409).send({ error: error.message, currentVersion: error.currentVersion });
|
|
7318
|
+
if (error instanceof DocumentNotFoundError2)
|
|
7319
|
+
return reply.status(404).send({ error: error.message });
|
|
7320
|
+
if (error instanceof DocumentPathError2)
|
|
7321
|
+
return reply.status(400).send({ error: error.message });
|
|
7322
|
+
const triggerError = replyForTriggerError(error, reply);
|
|
7323
|
+
if (triggerError)
|
|
7324
|
+
return triggerError;
|
|
7325
|
+
return handleEnablementError(error, reply);
|
|
7326
|
+
});
|
|
7327
|
+
const typed = privateApp.withTypeProvider();
|
|
7328
|
+
typed.post("/projects/:projectId/private-state/read", {
|
|
7329
|
+
schema: {
|
|
7330
|
+
params: Project,
|
|
7331
|
+
body: PrivateStateReadSchema,
|
|
7332
|
+
response: { 200: State, ...errors }
|
|
7333
|
+
}
|
|
7334
|
+
}, async (request, reply) => {
|
|
7335
|
+
if (!ctx.core)
|
|
7336
|
+
return reply.status(503).send({ error: "Private state is unavailable" });
|
|
7337
|
+
return ctx.core.privateState.read({
|
|
7338
|
+
...request.params,
|
|
7339
|
+
...request.body,
|
|
7340
|
+
identity: resolveIdentity(request)
|
|
7341
|
+
});
|
|
7342
|
+
});
|
|
7343
|
+
typed.put("/projects/:projectId/private-state", {
|
|
7344
|
+
schema: {
|
|
7345
|
+
params: Project,
|
|
7346
|
+
body: StateWrite,
|
|
7347
|
+
response: { 200: State, ...errors }
|
|
7348
|
+
}
|
|
7349
|
+
}, async (request, reply) => {
|
|
7350
|
+
if (!ctx.core)
|
|
7351
|
+
return reply.status(503).send({ error: "Private state is unavailable" });
|
|
7352
|
+
return ctx.core.privateState.write({
|
|
7353
|
+
...request.params,
|
|
7354
|
+
...request.body,
|
|
7355
|
+
identity: resolveIdentity(request)
|
|
7356
|
+
});
|
|
7357
|
+
});
|
|
7358
|
+
typed.delete("/projects/:projectId/private-state", {
|
|
7359
|
+
schema: {
|
|
7360
|
+
params: Project,
|
|
7361
|
+
body: PrivateStateDeleteSchema,
|
|
7362
|
+
response: { 200: z16.object({ version: z16.number().int() }), ...errors }
|
|
7363
|
+
}
|
|
7364
|
+
}, async (request, reply) => {
|
|
7365
|
+
if (!ctx.core)
|
|
7366
|
+
return reply.status(503).send({ error: "Private state is unavailable" });
|
|
7367
|
+
return ctx.core.privateState.delete({
|
|
7368
|
+
...request.params,
|
|
7369
|
+
...request.body,
|
|
7370
|
+
identity: resolveIdentity(request)
|
|
7371
|
+
});
|
|
7372
|
+
});
|
|
7373
|
+
typed.post("/projects/:projectId/notifications", {
|
|
7374
|
+
schema: {
|
|
7375
|
+
params: Project,
|
|
7376
|
+
body: PublishNotificationSchema,
|
|
7377
|
+
response: {
|
|
7378
|
+
200: z16.object({ published: z16.literal(true) }),
|
|
7379
|
+
...errors
|
|
7380
|
+
}
|
|
7381
|
+
}
|
|
7382
|
+
}, async (request, reply) => {
|
|
7383
|
+
if (!ctx.core)
|
|
7384
|
+
return reply.status(503).send({ error: "Notifications are unavailable" });
|
|
7385
|
+
return ctx.core.notifications.notify({
|
|
7386
|
+
...request.params,
|
|
7387
|
+
...request.body,
|
|
7388
|
+
identity: resolveIdentity(request)
|
|
7389
|
+
});
|
|
7390
|
+
});
|
|
7391
|
+
typed.get("/projects/:projectId/private-workflows", {
|
|
7392
|
+
schema: {
|
|
7393
|
+
params: Project,
|
|
7394
|
+
response: { 200: z16.array(SessionArtifactSchema), ...errors }
|
|
7395
|
+
}
|
|
7396
|
+
}, async (request, reply) => {
|
|
7397
|
+
if (!ctx.core)
|
|
7398
|
+
return reply.status(503).send({ error: "Private workflows are unavailable" });
|
|
7399
|
+
return ctx.core.sessionArtifacts.list({
|
|
7400
|
+
...request.params,
|
|
7401
|
+
identity: resolveIdentity(request),
|
|
7402
|
+
lifetime: "member"
|
|
7403
|
+
});
|
|
7404
|
+
});
|
|
7405
|
+
typed.post("/projects/:projectId/private-workflows", {
|
|
7406
|
+
bodyLimit: 6 * 1024 * 1024,
|
|
7407
|
+
schema: {
|
|
7408
|
+
params: Project,
|
|
7409
|
+
body: z16.object({
|
|
7410
|
+
name: z16.string().min(1).max(100),
|
|
7411
|
+
title: z16.string().max(200).optional(),
|
|
7412
|
+
source: z16.string().max(5 * 1024 * 1024),
|
|
7413
|
+
files: z16.record(z16.string(), z16.string()).optional()
|
|
7414
|
+
}),
|
|
7415
|
+
response: { 201: SessionArtifactSchema, ...errors }
|
|
7416
|
+
}
|
|
7417
|
+
}, async (request, reply) => {
|
|
7418
|
+
if (!ctx.core)
|
|
7419
|
+
return reply.status(503).send({ error: "Private workflows are unavailable" });
|
|
7420
|
+
return reply.status(201).send(await ctx.core.sessionArtifacts.create({
|
|
7421
|
+
...request.params,
|
|
7422
|
+
...request.body,
|
|
7423
|
+
identity: resolveIdentity(request),
|
|
7424
|
+
lifetime: "member",
|
|
7425
|
+
kind: "workflow"
|
|
7426
|
+
}));
|
|
7427
|
+
});
|
|
7428
|
+
typed.post("/projects/:projectId/private-workflows/:artifactId/preview", {
|
|
7429
|
+
schema: {
|
|
7430
|
+
params: Artifact,
|
|
7431
|
+
body: Revision,
|
|
7432
|
+
response: { 200: WorkflowEnablementPreviewSchema, ...errors }
|
|
7433
|
+
}
|
|
7434
|
+
}, async (request, reply) => {
|
|
7435
|
+
if (!ctx.core)
|
|
7436
|
+
return reply.status(503).send({ error: "Private workflows are unavailable" });
|
|
7437
|
+
return ctx.core.privateWorkflows.preview({
|
|
7438
|
+
...request.params,
|
|
7439
|
+
...request.body,
|
|
7440
|
+
identity: resolveIdentity(request)
|
|
7441
|
+
});
|
|
7442
|
+
});
|
|
7443
|
+
typed.post("/projects/:projectId/private-workflows/:artifactId/activate", {
|
|
7444
|
+
schema: {
|
|
7445
|
+
params: Artifact,
|
|
7446
|
+
body: Revision.extend({ consentDigest: z16.string() }),
|
|
7447
|
+
response: { 200: WorkflowEnablementSchema, ...errors }
|
|
7448
|
+
}
|
|
7449
|
+
}, async (request, reply) => {
|
|
7450
|
+
if (!ctx.core)
|
|
7451
|
+
return reply.status(503).send({ error: "Private workflows are unavailable" });
|
|
7452
|
+
return ctx.core.privateWorkflows.activate({
|
|
7453
|
+
...request.params,
|
|
7454
|
+
...request.body,
|
|
7455
|
+
identity: resolveIdentity(request)
|
|
7456
|
+
});
|
|
7457
|
+
});
|
|
7458
|
+
typed.post("/projects/:projectId/private-workflows/:artifactId/stop", {
|
|
7459
|
+
schema: {
|
|
7460
|
+
params: Artifact,
|
|
7461
|
+
response: { 200: z16.object({ stopped: z16.boolean() }), ...errors }
|
|
7462
|
+
}
|
|
7463
|
+
}, async (request, reply) => {
|
|
7464
|
+
if (!ctx.core)
|
|
7465
|
+
return reply.status(503).send({ error: "Private workflows are unavailable" });
|
|
7466
|
+
return ctx.core.privateWorkflows.stop({
|
|
7467
|
+
...request.params,
|
|
7468
|
+
identity: resolveIdentity(request)
|
|
7469
|
+
});
|
|
7470
|
+
});
|
|
7471
|
+
typed.post("/projects/:projectId/private-workflows/:artifactId/run", {
|
|
7472
|
+
schema: {
|
|
7473
|
+
params: Artifact,
|
|
7474
|
+
body: Revision.extend({ input: JsonValueSchema.optional() }),
|
|
7475
|
+
response: { 200: RunSchema, ...errors }
|
|
7476
|
+
}
|
|
7477
|
+
}, async (request, reply) => {
|
|
7478
|
+
if (!ctx.core)
|
|
7479
|
+
return reply.status(503).send({ error: "Private workflows are unavailable" });
|
|
7480
|
+
return ctx.core.privateWorkflows.run({
|
|
7481
|
+
...request.params,
|
|
7482
|
+
...request.body,
|
|
7483
|
+
identity: resolveIdentity(request)
|
|
7484
|
+
});
|
|
7485
|
+
});
|
|
7486
|
+
});
|
|
7487
|
+
}
|
|
7488
|
+
|
|
7489
|
+
// src/routes/project-mcp.ts
|
|
7490
|
+
import { agentCapabilityTools } from "@catamorphic/sandbox";
|
|
7491
|
+
import { z as z20 } from "zod";
|
|
7492
|
+
|
|
7493
|
+
// src/project-mcp-program.ts
|
|
7494
|
+
import {
|
|
7495
|
+
AccessDeniedError as AccessDeniedError8,
|
|
7496
|
+
assertMayManageRolePolicy,
|
|
7497
|
+
assertProjectPermission as assertProjectPermission2,
|
|
7498
|
+
DeploymentBlockedError,
|
|
7499
|
+
effectiveProjectPermissions as effectiveProjectPermissions2,
|
|
7500
|
+
hasProjectPermission,
|
|
7501
|
+
mayUseProject
|
|
7502
|
+
} from "@catamorphic/core";
|
|
7503
|
+
import { checkProject } from "@catamorphic/parser";
|
|
7504
|
+
import {
|
|
7505
|
+
isProjectPathWithin,
|
|
7506
|
+
PROJECT_APPS_DIR,
|
|
7507
|
+
PROJECT_CONTRACTS_DIR,
|
|
7508
|
+
PROJECT_WORKFLOWS_DIR
|
|
7509
|
+
} from "@catamorphic/workflow/project-layout";
|
|
7510
|
+
var READ_ONLY = { readOnlyHint: true };
|
|
7511
|
+
var TOOL_SYNC_BUDGET_MS = 30000;
|
|
7512
|
+
function programTools(core, identity, projectId) {
|
|
7513
|
+
if (!mayUseProject(identity, projectId))
|
|
7514
|
+
return [];
|
|
7515
|
+
const tools = [overviewTool(core, identity, projectId)];
|
|
7516
|
+
const may = (permission) => hasProjectPermission(identity, projectId, permission);
|
|
7517
|
+
if (may("program:write")) {
|
|
7518
|
+
tools.push({
|
|
7519
|
+
definition: {
|
|
7520
|
+
name: "program_files",
|
|
7521
|
+
description: "Your draft of the project's program (workflows, apps, agents, roles and skills under .work/, plus any other files). Without a path, lists files and your unpublished changes; with a path, returns that file from your draft.",
|
|
7522
|
+
inputSchema: {
|
|
7523
|
+
type: "object",
|
|
7524
|
+
properties: {
|
|
7525
|
+
path: { type: "string", description: "File to read" }
|
|
7526
|
+
}
|
|
7527
|
+
}
|
|
7528
|
+
},
|
|
7529
|
+
call: guarded(async (args) => {
|
|
7530
|
+
const status = await refreshDraft(core, identity, projectId);
|
|
7531
|
+
const path = str(args.path);
|
|
7532
|
+
if (path)
|
|
7533
|
+
return {
|
|
7534
|
+
path,
|
|
7535
|
+
content: await core.projects.readFile(identity, projectId, path)
|
|
7536
|
+
};
|
|
7537
|
+
const files = await core.projects.listFiles(identity, projectId);
|
|
7538
|
+
return {
|
|
7539
|
+
files: files.map((file) => file.path).sort(),
|
|
7540
|
+
...draftSummary(status)
|
|
7541
|
+
};
|
|
7542
|
+
})
|
|
7543
|
+
}, {
|
|
7544
|
+
definition: {
|
|
7545
|
+
name: "program_write",
|
|
7546
|
+
description: "Change files in your draft of the program. Nothing reaches members until program_deploy (or propose_change). Role files under .work/roles need roles:write.",
|
|
7547
|
+
inputSchema: {
|
|
7548
|
+
type: "object",
|
|
7549
|
+
properties: {
|
|
7550
|
+
changes: {
|
|
7551
|
+
type: "array",
|
|
7552
|
+
items: {
|
|
7553
|
+
type: "object",
|
|
7554
|
+
properties: {
|
|
7555
|
+
path: { type: "string" },
|
|
7556
|
+
content: { type: "string" },
|
|
7557
|
+
delete: { type: "boolean" }
|
|
7558
|
+
},
|
|
7559
|
+
required: ["path"]
|
|
7560
|
+
}
|
|
7561
|
+
}
|
|
7562
|
+
},
|
|
7563
|
+
required: ["changes"]
|
|
7564
|
+
}
|
|
7565
|
+
},
|
|
7566
|
+
call: guarded(async (args) => {
|
|
7567
|
+
const changes = Array.isArray(args.changes) ? args.changes : [];
|
|
7568
|
+
if (changes.length === 0)
|
|
7569
|
+
throw new Error("changes is required");
|
|
7570
|
+
await refreshDraft(core, identity, projectId);
|
|
7571
|
+
const draftChanges = changes.map((raw) => {
|
|
7572
|
+
const change = asRecord(raw);
|
|
7573
|
+
const path = str(change.path);
|
|
7574
|
+
if (!path)
|
|
7575
|
+
throw new Error("Each change needs a path");
|
|
7576
|
+
if (change.delete === true)
|
|
7577
|
+
return { path, delete: true };
|
|
7578
|
+
const content = str(change.content);
|
|
7579
|
+
if (content === undefined)
|
|
7580
|
+
throw new Error(`${path}: pass content or delete: true`);
|
|
7581
|
+
return { path, content };
|
|
7582
|
+
});
|
|
7583
|
+
await core.projects.writeFiles({
|
|
7584
|
+
identity,
|
|
7585
|
+
projectId,
|
|
7586
|
+
changes: draftChanges
|
|
7587
|
+
});
|
|
7588
|
+
return { written: draftChanges.map((change) => change.path) };
|
|
7589
|
+
})
|
|
7590
|
+
}, {
|
|
7591
|
+
definition: {
|
|
7592
|
+
name: "program_check",
|
|
7593
|
+
description: "Refresh your draft's generated types (the trigger kinds this server offers, in .work/workflows/src/work-triggers.d.ts, and each app's workflow API types), then validate it the way publishing does: workflow and app parse errors and trigger configurations. Run it after writing and before program_deploy.",
|
|
7594
|
+
inputSchema: { type: "object", properties: {} }
|
|
7595
|
+
},
|
|
7596
|
+
call: guarded(async () => checkDraft(core, identity, projectId))
|
|
7597
|
+
});
|
|
7598
|
+
}
|
|
7599
|
+
if (may("program:write") && may("program:publish")) {
|
|
7600
|
+
tools.push({
|
|
7601
|
+
definition: {
|
|
7602
|
+
name: "program_deploy",
|
|
7603
|
+
description: "Publish your draft as the project's production program: workflows move to it, and every app it changes (or that was never published) is built and published, with each app's result reported. Refused while program_check reports errors, and for projects whose program lives in a linked repository (use propose_change there).",
|
|
7604
|
+
inputSchema: {
|
|
7605
|
+
type: "object",
|
|
7606
|
+
properties: {
|
|
7607
|
+
message: {
|
|
7608
|
+
type: "string",
|
|
7609
|
+
description: "What changed and why, as a commit message"
|
|
7610
|
+
}
|
|
7611
|
+
},
|
|
7612
|
+
required: ["message"]
|
|
7613
|
+
}
|
|
7614
|
+
},
|
|
7615
|
+
call: guarded(async (args) => {
|
|
7616
|
+
const message = str(args.message);
|
|
7617
|
+
if (!message)
|
|
7618
|
+
throw new Error("message is required");
|
|
7619
|
+
const project = await core.projects.get(identity, projectId);
|
|
7620
|
+
if (project.remoteUrl)
|
|
7621
|
+
throw new Error(`This project's program is published from ${project.remoteUrl}. Open a pull request there, or use propose_change.`);
|
|
7622
|
+
const check = await checkDraft(core, identity, projectId);
|
|
7623
|
+
if (!check.ok)
|
|
7624
|
+
return { status: "blocked", ...check };
|
|
7625
|
+
const before = await core.deployment.getStatus(identity.tenantId, projectId, identity.externalUserId);
|
|
7626
|
+
const result = await core.deployment.deploy(identity.tenantId, projectId, identity.externalUserId, {
|
|
7627
|
+
message,
|
|
7628
|
+
guardPublishedPaths: (paths) => assertMayManageRolePolicy(identity, projectId, paths)
|
|
7629
|
+
});
|
|
7630
|
+
const published = result.status === "deployed" ? result.commitSha : result.status === "nothing-to-deploy" ? before.remoteHead : null;
|
|
7631
|
+
const apps = published ? await publishApps({
|
|
7632
|
+
core,
|
|
7633
|
+
identity,
|
|
7634
|
+
projectId,
|
|
7635
|
+
base: result.status === "deployed" ? before.remoteHead : published,
|
|
7636
|
+
head: published
|
|
7637
|
+
}) : [];
|
|
7638
|
+
return { ...result, apps, warnings: check.findings };
|
|
7639
|
+
})
|
|
7640
|
+
});
|
|
7641
|
+
}
|
|
7642
|
+
tools.push({
|
|
7643
|
+
definition: {
|
|
7644
|
+
name: "workflow_run",
|
|
7645
|
+
description: "Run a deployed workflow with an input. Waits up to 30 seconds: a finished run returns its output, a longer one returns its runId for run_details. Pass environment to choose where it runs (names in project_overview).",
|
|
7646
|
+
inputSchema: {
|
|
7647
|
+
type: "object",
|
|
7648
|
+
properties: {
|
|
7649
|
+
workflow: { type: "string" },
|
|
7650
|
+
input: {
|
|
7651
|
+
description: "The workflow's input, as JSON of the workflow's input type",
|
|
7652
|
+
type: ["object", "array", "string", "number", "boolean", "null"]
|
|
7653
|
+
},
|
|
7654
|
+
environment: { type: "string" }
|
|
7655
|
+
},
|
|
7656
|
+
required: ["workflow"]
|
|
7657
|
+
}
|
|
7658
|
+
},
|
|
7659
|
+
call: guarded(async (args) => {
|
|
7660
|
+
const workflowName = str(args.workflow);
|
|
7661
|
+
if (!workflowName)
|
|
7662
|
+
throw new Error("workflow is required");
|
|
7663
|
+
const environment = str(args.environment);
|
|
7664
|
+
return core.runs.call({
|
|
7665
|
+
identity,
|
|
7666
|
+
projectId,
|
|
7667
|
+
workflowName,
|
|
7668
|
+
...environment ? { environment } : {},
|
|
7669
|
+
...args.input === undefined ? {} : { input: args.input },
|
|
7670
|
+
budgetMs: TOOL_SYNC_BUDGET_MS
|
|
7671
|
+
});
|
|
7672
|
+
})
|
|
7673
|
+
}, {
|
|
7674
|
+
definition: {
|
|
7675
|
+
name: "workflow_runs",
|
|
7676
|
+
description: "Recent runs of the project's workflows, newest first, with status and errors. Filter by workflow.",
|
|
7677
|
+
inputSchema: {
|
|
7678
|
+
type: "object",
|
|
7679
|
+
properties: {
|
|
7680
|
+
workflow: { type: "string" },
|
|
7681
|
+
limit: { type: "integer", minimum: 1, maximum: 100 }
|
|
7682
|
+
}
|
|
7683
|
+
},
|
|
7684
|
+
annotations: READ_ONLY
|
|
7685
|
+
},
|
|
7686
|
+
call: guarded(async (args) => {
|
|
7687
|
+
const workflowName = str(args.workflow);
|
|
7688
|
+
return core.runs.list({
|
|
7689
|
+
identity,
|
|
7690
|
+
projectId,
|
|
7691
|
+
...workflowName ? { workflowName } : {},
|
|
7692
|
+
limit: typeof args.limit === "number" ? args.limit : 20
|
|
7693
|
+
});
|
|
7694
|
+
})
|
|
7695
|
+
}, {
|
|
6949
7696
|
definition: {
|
|
6950
7697
|
name: "run_details",
|
|
6951
7698
|
description: "One run in full: status, input, output, error, and each step with its result, for debugging a workflow.",
|
|
@@ -6977,7 +7724,7 @@ function overviewTool(core, identity, projectId) {
|
|
|
6977
7724
|
},
|
|
6978
7725
|
call: guarded(async () => {
|
|
6979
7726
|
const optional = (load) => load().catch((error) => {
|
|
6980
|
-
if (error instanceof
|
|
7727
|
+
if (error instanceof AccessDeniedError8)
|
|
6981
7728
|
return;
|
|
6982
7729
|
throw error;
|
|
6983
7730
|
});
|
|
@@ -7118,7 +7865,7 @@ function guarded(fn) {
|
|
|
7118
7865
|
try {
|
|
7119
7866
|
return toolValue(await fn(args));
|
|
7120
7867
|
} catch (error) {
|
|
7121
|
-
if (error instanceof
|
|
7868
|
+
if (error instanceof AccessDeniedError8)
|
|
7122
7869
|
return toolError2("Your roles do not allow that.");
|
|
7123
7870
|
const code = typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
|
|
7124
7871
|
if (code === "ENOENT")
|
|
@@ -7170,7 +7917,7 @@ import {
|
|
|
7170
7917
|
setSessionMetadataInputSchema
|
|
7171
7918
|
} from "@catamorphic/agent-protocol";
|
|
7172
7919
|
import {
|
|
7173
|
-
AccessDeniedError as
|
|
7920
|
+
AccessDeniedError as AccessDeniedError9,
|
|
7174
7921
|
AgentTurnUnsettledError,
|
|
7175
7922
|
EVERY_ARTIFACT,
|
|
7176
7923
|
mayUseProject as mayUseProject2,
|
|
@@ -7179,22 +7926,22 @@ import {
|
|
|
7179
7926
|
resolveScope,
|
|
7180
7927
|
SESSION_ACTION_SCHEMAS
|
|
7181
7928
|
} from "@catamorphic/core";
|
|
7182
|
-
import { z as
|
|
7929
|
+
import { z as z19 } from "zod";
|
|
7183
7930
|
|
|
7184
7931
|
// src/app-presentation-tools.ts
|
|
7185
|
-
import { APP_ICON_DESCRIPTIONS, APP_ICON_NAMES as
|
|
7186
|
-
import { z as
|
|
7187
|
-
var Input =
|
|
7188
|
-
appName:
|
|
7189
|
-
icon:
|
|
7190
|
-
title:
|
|
7932
|
+
import { APP_ICON_DESCRIPTIONS, APP_ICON_NAMES as APP_ICON_NAMES4 } from "@catamorphic/app";
|
|
7933
|
+
import { z as z17 } from "zod";
|
|
7934
|
+
var Input = z17.object({
|
|
7935
|
+
appName: z17.string().min(1),
|
|
7936
|
+
icon: z17.enum(APP_ICON_NAMES4).optional(),
|
|
7937
|
+
title: z17.string().trim().min(1).max(200).optional()
|
|
7191
7938
|
}).refine((value) => value.icon !== undefined || value.title !== undefined, "Supply a title or icon");
|
|
7192
7939
|
function appPresentationTool(core, identity, projectId) {
|
|
7193
7940
|
return {
|
|
7194
7941
|
definition: {
|
|
7195
7942
|
name: "set_app_presentation",
|
|
7196
|
-
description: `Set an app's title and/or canonical icon without rebuilding or publishing. Use a short, descriptive title that names what the app does or contains. Match the language of the task, avoid generic labels like Session app, and keep the title stable through revisions. There is no required title template. Use the returned appName for temporary apps, not their display title. All reviews use review. Choose default when in doubt; never infer a specialized type just from a filename. Choices: ${
|
|
7197
|
-
inputSchema:
|
|
7943
|
+
description: `Set an app's title and/or canonical icon without rebuilding or publishing. Use a short, descriptive title that names what the app does or contains. Match the language of the task, avoid generic labels like Session app, and keep the title stable through revisions. There is no required title template. Use the returned appName for temporary apps, not their display title. All reviews use review. Choose default when in doubt; never infer a specialized type just from a filename. Choices: ${APP_ICON_NAMES4.map((name) => `${name}: ${APP_ICON_DESCRIPTIONS[name]}`).join("; ")}.`,
|
|
7944
|
+
inputSchema: z17.toJSONSchema(Input)
|
|
7198
7945
|
},
|
|
7199
7946
|
call: async (raw) => {
|
|
7200
7947
|
try {
|
|
@@ -7213,28 +7960,28 @@ function appPresentationTool(core, identity, projectId) {
|
|
|
7213
7960
|
}
|
|
7214
7961
|
|
|
7215
7962
|
// src/session-artifact-tools.ts
|
|
7216
|
-
import { APP_ICON_NAMES as
|
|
7217
|
-
import { z as
|
|
7218
|
-
var Input2 =
|
|
7219
|
-
action:
|
|
7220
|
-
sessionId:
|
|
7221
|
-
artifactId:
|
|
7222
|
-
kind:
|
|
7223
|
-
name:
|
|
7224
|
-
title:
|
|
7225
|
-
icon:
|
|
7226
|
-
source:
|
|
7227
|
-
files:
|
|
7228
|
-
revision:
|
|
7229
|
-
environment:
|
|
7230
|
-
input:
|
|
7963
|
+
import { APP_ICON_NAMES as APP_ICON_NAMES5 } from "@catamorphic/app";
|
|
7964
|
+
import { z as z18 } from "zod";
|
|
7965
|
+
var Input2 = z18.object({
|
|
7966
|
+
action: z18.enum(["create", "list", "read", "update", "discard", "run"]),
|
|
7967
|
+
sessionId: z18.string().uuid().optional(),
|
|
7968
|
+
artifactId: z18.string().uuid().optional(),
|
|
7969
|
+
kind: z18.enum(["app", "workflow"]).optional(),
|
|
7970
|
+
name: z18.string().max(100).optional(),
|
|
7971
|
+
title: z18.string().max(200).optional(),
|
|
7972
|
+
icon: z18.enum(APP_ICON_NAMES5).optional(),
|
|
7973
|
+
source: z18.string().optional(),
|
|
7974
|
+
files: z18.record(z18.string(), z18.string().nullable()).optional(),
|
|
7975
|
+
revision: z18.number().int().positive().optional(),
|
|
7976
|
+
environment: z18.string().optional(),
|
|
7977
|
+
input: z18.json().optional()
|
|
7231
7978
|
});
|
|
7232
7979
|
function sessionArtifactTool(core, identity, projectId, currentSessionId) {
|
|
7233
7980
|
return {
|
|
7234
7981
|
definition: {
|
|
7235
7982
|
name: "session_artifact",
|
|
7236
7983
|
description: "Create, read, update, run or discard a temporary app or workflow owned by this session. Load the session-artifacts skill first. App source is a React component exporting default; the host supplies the standard app scaffold and builds it immediately. Additional files use ordinary workspace paths and may include shared components, dependencies and helper workflows. Workflow source is an ordinary exported defineWorkflow. No files are added to the user's checkout. Results survive closing tabs and remain available with the chat. Update requires the revision returned by read; files are explicit changed paths. Apps return their ordinary app:<appName> target. Creating a workflow does not run or enable it; use run for a one-off invocation, and the watcher tool for temporary scheduled activation. Discard prevents new use. Saving reusable work into the project is a separate selected-file change.",
|
|
7237
|
-
inputSchema:
|
|
7984
|
+
inputSchema: z18.toJSONSchema(Input2)
|
|
7238
7985
|
},
|
|
7239
7986
|
call: async (raw) => {
|
|
7240
7987
|
try {
|
|
@@ -7374,7 +8121,7 @@ function surfaceTools(core, identity, projectId, features = { publications: "pub
|
|
|
7374
8121
|
try {
|
|
7375
8122
|
return toolValue(await fn(args));
|
|
7376
8123
|
} catch (error) {
|
|
7377
|
-
if (error instanceof
|
|
8124
|
+
if (error instanceof AccessDeniedError9) {
|
|
7378
8125
|
return toolError2("Not authorized for that path or agent.");
|
|
7379
8126
|
}
|
|
7380
8127
|
return toolError2(error instanceof Error ? error.message : String(error));
|
|
@@ -7759,7 +8506,7 @@ function surfaceTools(core, identity, projectId, features = { publications: "pub
|
|
|
7759
8506
|
definition: {
|
|
7760
8507
|
name: "set_session_metadata",
|
|
7761
8508
|
description: SET_SESSION_METADATA_DESCRIPTION,
|
|
7762
|
-
inputSchema:
|
|
8509
|
+
inputSchema: z19.toJSONSchema(setSessionMetadataInputSchema)
|
|
7763
8510
|
},
|
|
7764
8511
|
call: guarded(async (args) => {
|
|
7765
8512
|
const values = sessionMetadataToolWrite(args);
|
|
@@ -7837,7 +8584,7 @@ function surfaceTools(core, identity, projectId, features = { publications: "pub
|
|
|
7837
8584
|
definition: {
|
|
7838
8585
|
name: `session_${operation}`,
|
|
7839
8586
|
description: `Session ${operation}. Uses the same authorized operation as workflows. Name the chat by sessionId, or by the project's key for it (key, with audience "project" for the project chat). Mutations require a stable idempotencyKey; retries return the existing result. Load the session-workflows skill for examples.`,
|
|
7840
|
-
inputSchema:
|
|
8587
|
+
inputSchema: z19.toJSONSchema(SESSION_ACTION_SCHEMAS[operation])
|
|
7841
8588
|
},
|
|
7842
8589
|
call: guarded(async (args) => {
|
|
7843
8590
|
const source = currentSessionId ? await sessions.get(identity, projectId, currentSessionId) : undefined;
|
|
@@ -8047,7 +8794,7 @@ function registerProjectMcpRoutes(app, ctx) {
|
|
|
8047
8794
|
...gatewayTools.map((tool) => ({
|
|
8048
8795
|
name: tool.name,
|
|
8049
8796
|
description: tool.description,
|
|
8050
|
-
inputSchema:
|
|
8797
|
+
inputSchema: z20.toJSONSchema(z20.object(tool.parameters))
|
|
8051
8798
|
})),
|
|
8052
8799
|
...tools.filter((tool) => !gatewayTools.some((gateway) => gateway.name === tool.name)).map(toolDefinition),
|
|
8053
8800
|
...tools.length > 0 || core.mcpToolKinds.length > 0 ? [POLL_RUN_TOOL_DEFINITION] : [],
|
|
@@ -8213,7 +8960,7 @@ import {
|
|
|
8213
8960
|
ProjectFileNotTextError,
|
|
8214
8961
|
ProjectNotFoundError as ProjectNotFoundError8
|
|
8215
8962
|
} from "@catamorphic/core";
|
|
8216
|
-
import { z as
|
|
8963
|
+
import { z as z21 } from "zod";
|
|
8217
8964
|
function toDto(project) {
|
|
8218
8965
|
return {
|
|
8219
8966
|
id: project.id,
|
|
@@ -8326,7 +9073,7 @@ function registerProjectRoutes(app, ctx) {
|
|
|
8326
9073
|
schema: {
|
|
8327
9074
|
params: ProjectIdParamsSchema,
|
|
8328
9075
|
response: {
|
|
8329
|
-
200:
|
|
9076
|
+
200: z21.object({ deleted: z21.boolean() }),
|
|
8330
9077
|
404: ErrorSchema,
|
|
8331
9078
|
503: ErrorSchema
|
|
8332
9079
|
}
|
|
@@ -8534,9 +9281,9 @@ function registerProjectRoutes(app, ctx) {
|
|
|
8534
9281
|
url: "/projects/:projectId/diff",
|
|
8535
9282
|
schema: {
|
|
8536
9283
|
params: ProjectIdParamsSchema,
|
|
8537
|
-
querystring:
|
|
8538
|
-
base:
|
|
8539
|
-
head:
|
|
9284
|
+
querystring: z21.object({
|
|
9285
|
+
base: z21.string().min(1),
|
|
9286
|
+
head: z21.string().min(1)
|
|
8540
9287
|
}),
|
|
8541
9288
|
response: {
|
|
8542
9289
|
200: DiffEntrySchema.array(),
|
|
@@ -8667,7 +9414,7 @@ function registerProjectRoutes(app, ctx) {
|
|
|
8667
9414
|
params: ProjectIdParamsSchema,
|
|
8668
9415
|
body: ResolveConflictsSchema,
|
|
8669
9416
|
response: {
|
|
8670
|
-
200:
|
|
9417
|
+
200: z21.object({ commitSha: z21.string() }),
|
|
8671
9418
|
404: ErrorSchema,
|
|
8672
9419
|
503: ErrorSchema
|
|
8673
9420
|
}
|
|
@@ -8698,18 +9445,18 @@ function registerProjectRoutes(app, ctx) {
|
|
|
8698
9445
|
url: "/projects/:projectId/ai-resolve-conflicts",
|
|
8699
9446
|
schema: {
|
|
8700
9447
|
params: ProjectIdParamsSchema,
|
|
8701
|
-
body:
|
|
8702
|
-
conflicts:
|
|
8703
|
-
path:
|
|
8704
|
-
base:
|
|
8705
|
-
ours:
|
|
8706
|
-
theirs:
|
|
9448
|
+
body: z21.object({
|
|
9449
|
+
conflicts: z21.array(z21.object({
|
|
9450
|
+
path: z21.string(),
|
|
9451
|
+
base: z21.string().nullable(),
|
|
9452
|
+
ours: z21.string().nullable(),
|
|
9453
|
+
theirs: z21.string().nullable()
|
|
8707
9454
|
}))
|
|
8708
9455
|
}),
|
|
8709
9456
|
response: {
|
|
8710
|
-
200:
|
|
8711
|
-
resolutions:
|
|
8712
|
-
notes:
|
|
9457
|
+
200: z21.object({
|
|
9458
|
+
resolutions: z21.record(z21.string(), z21.string()),
|
|
9459
|
+
notes: z21.string().optional()
|
|
8713
9460
|
}),
|
|
8714
9461
|
503: ErrorSchema
|
|
8715
9462
|
}
|
|
@@ -8732,9 +9479,9 @@ function registerProjectRoutes(app, ctx) {
|
|
|
8732
9479
|
url: "/projects/:projectId/files-at-ref",
|
|
8733
9480
|
schema: {
|
|
8734
9481
|
params: ProjectIdParamsSchema,
|
|
8735
|
-
querystring: RefQuerySchema.extend({ ref:
|
|
9482
|
+
querystring: RefQuerySchema.extend({ ref: z21.string().min(1) }),
|
|
8736
9483
|
response: {
|
|
8737
|
-
200:
|
|
9484
|
+
200: z21.record(z21.string(), z21.string()),
|
|
8738
9485
|
404: ErrorSchema,
|
|
8739
9486
|
503: ErrorSchema
|
|
8740
9487
|
}
|
|
@@ -8771,14 +9518,14 @@ async function safeListWorkflows(core, identity, projectId) {
|
|
|
8771
9518
|
|
|
8772
9519
|
// src/routes/publications.ts
|
|
8773
9520
|
import {
|
|
8774
|
-
DocumentNotFoundError as
|
|
8775
|
-
DocumentPathError as
|
|
9521
|
+
DocumentNotFoundError as DocumentNotFoundError3,
|
|
9522
|
+
DocumentPathError as DocumentPathError3,
|
|
8776
9523
|
ProjectNotFoundError as ProjectNotFoundError9,
|
|
8777
9524
|
PublicationNotFoundError,
|
|
8778
9525
|
PublicationSlugError,
|
|
8779
9526
|
PublicationSlugTakenError
|
|
8780
9527
|
} from "@catamorphic/core";
|
|
8781
|
-
import { z as
|
|
9528
|
+
import { z as z22 } from "zod";
|
|
8782
9529
|
function registerPublicationRoutes(app, ctx) {
|
|
8783
9530
|
const typed = app.withTypeProvider();
|
|
8784
9531
|
const core = () => {
|
|
@@ -8800,7 +9547,7 @@ function registerPublicationRoutes(app, ctx) {
|
|
|
8800
9547
|
if (err instanceof PublicationNotFoundError) {
|
|
8801
9548
|
return reply.status(404).send({ error: err.message });
|
|
8802
9549
|
}
|
|
8803
|
-
if (err instanceof
|
|
9550
|
+
if (err instanceof DocumentPathError3 || err instanceof PublicationSlugError) {
|
|
8804
9551
|
return reply.status(400).send({ error: err.message });
|
|
8805
9552
|
}
|
|
8806
9553
|
if (err instanceof PublicationSlugTakenError) {
|
|
@@ -8867,7 +9614,7 @@ function registerPublicationRoutes(app, ctx) {
|
|
|
8867
9614
|
url: "/projects/:projectId/publications/:slug",
|
|
8868
9615
|
schema: {
|
|
8869
9616
|
params: PublicationParamsSchema,
|
|
8870
|
-
response: { 204:
|
|
9617
|
+
response: { 204: z22.null(), 404: ErrorSchema }
|
|
8871
9618
|
},
|
|
8872
9619
|
handler: async (request, reply) => {
|
|
8873
9620
|
try {
|
|
@@ -8903,7 +9650,7 @@ function registerPublicationRoutes(app, ctx) {
|
|
|
8903
9650
|
}
|
|
8904
9651
|
return reply.send(Buffer.from(doc.bytes));
|
|
8905
9652
|
} catch (err) {
|
|
8906
|
-
if (err instanceof
|
|
9653
|
+
if (err instanceof DocumentNotFoundError3 || err instanceof DocumentPathError3) {
|
|
8907
9654
|
return reply.status(404).send({ error: "Not found" });
|
|
8908
9655
|
}
|
|
8909
9656
|
throw err;
|
|
@@ -8939,7 +9686,7 @@ import {
|
|
|
8939
9686
|
RunPauseNotFoundError,
|
|
8940
9687
|
RunResumeConflictError
|
|
8941
9688
|
} from "@catamorphic/core";
|
|
8942
|
-
import { z as
|
|
9689
|
+
import { z as z23 } from "zod";
|
|
8943
9690
|
function registerRunRoutes(app, ctx) {
|
|
8944
9691
|
const typed = app.withTypeProvider();
|
|
8945
9692
|
typed.route({
|
|
@@ -9107,7 +9854,7 @@ function registerRunRoutes(app, ctx) {
|
|
|
9107
9854
|
schema: {
|
|
9108
9855
|
params: RunItemParamsSchema,
|
|
9109
9856
|
response: {
|
|
9110
|
-
200:
|
|
9857
|
+
200: z23.array(BatchItemStepSchema),
|
|
9111
9858
|
404: ErrorSchema,
|
|
9112
9859
|
409: ErrorSchema,
|
|
9113
9860
|
503: ErrorSchema
|
|
@@ -9136,279 +9883,7 @@ function handleRunError(args) {
|
|
|
9136
9883
|
if (args.error instanceof RunCapabilityError2 || args.error instanceof RunResumeConflictError) {
|
|
9137
9884
|
return args.reply.status(409).send({ error: args.error.message });
|
|
9138
9885
|
}
|
|
9139
|
-
throw args.error;
|
|
9140
|
-
}
|
|
9141
|
-
|
|
9142
|
-
// src/routes/session-artifacts.ts
|
|
9143
|
-
import { APP_ICON_NAMES as APP_ICON_NAMES5 } from "@catamorphic/app";
|
|
9144
|
-
import { SessionArtifactNotFoundError } from "@catamorphic/core";
|
|
9145
|
-
import { z as z21 } from "zod";
|
|
9146
|
-
var SessionArtifactSchema = z21.object({
|
|
9147
|
-
id: z21.string().uuid(),
|
|
9148
|
-
projectId: z21.string().uuid(),
|
|
9149
|
-
sessionId: z21.string().uuid().nullable(),
|
|
9150
|
-
kind: z21.enum(["app", "workflow"]),
|
|
9151
|
-
name: z21.string(),
|
|
9152
|
-
title: z21.string(),
|
|
9153
|
-
sourcePath: z21.string(),
|
|
9154
|
-
remoteBranch: z21.string(),
|
|
9155
|
-
commitSha: z21.string(),
|
|
9156
|
-
revision: z21.number().int(),
|
|
9157
|
-
status: z21.enum(["active", "discarded"]),
|
|
9158
|
-
appName: z21.string().nullable(),
|
|
9159
|
-
createdAt: z21.string(),
|
|
9160
|
-
updatedAt: z21.string()
|
|
9161
|
-
});
|
|
9162
|
-
var SessionParams = z21.object({
|
|
9163
|
-
projectId: z21.string().uuid(),
|
|
9164
|
-
sessionId: z21.string().uuid()
|
|
9165
|
-
});
|
|
9166
|
-
var ArtifactParams = z21.object({
|
|
9167
|
-
projectId: z21.string().uuid(),
|
|
9168
|
-
artifactId: z21.string().uuid()
|
|
9169
|
-
});
|
|
9170
|
-
var Files = z21.record(z21.string().min(1).max(512), z21.string()).refine((files) => Object.keys(files).length <= 256);
|
|
9171
|
-
var Outcome = z21.object({
|
|
9172
|
-
artifact: SessionArtifactSchema,
|
|
9173
|
-
build: AppVersionSchema.nullable()
|
|
9174
|
-
});
|
|
9175
|
-
function registerSessionArtifactRoutes(app, ctx) {
|
|
9176
|
-
const typed = app.withTypeProvider();
|
|
9177
|
-
typed.route({
|
|
9178
|
-
method: "GET",
|
|
9179
|
-
url: "/projects/:projectId/agent/sessions/:sessionId/artifacts",
|
|
9180
|
-
schema: {
|
|
9181
|
-
params: SessionParams,
|
|
9182
|
-
response: {
|
|
9183
|
-
200: z21.array(SessionArtifactSchema),
|
|
9184
|
-
400: ErrorSchema,
|
|
9185
|
-
403: ErrorSchema,
|
|
9186
|
-
404: ErrorSchema,
|
|
9187
|
-
409: ErrorSchema,
|
|
9188
|
-
503: ErrorSchema
|
|
9189
|
-
}
|
|
9190
|
-
},
|
|
9191
|
-
handler: async (request, reply) => {
|
|
9192
|
-
if (!ctx.core)
|
|
9193
|
-
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
9194
|
-
return ctx.core.sessionArtifacts.list({
|
|
9195
|
-
...request.params,
|
|
9196
|
-
identity: resolveIdentity(request)
|
|
9197
|
-
});
|
|
9198
|
-
}
|
|
9199
|
-
});
|
|
9200
|
-
typed.route({
|
|
9201
|
-
method: "POST",
|
|
9202
|
-
url: "/projects/:projectId/agent/sessions/:sessionId/artifacts",
|
|
9203
|
-
bodyLimit: 6 * 1024 * 1024,
|
|
9204
|
-
schema: {
|
|
9205
|
-
params: SessionParams,
|
|
9206
|
-
body: z21.object({
|
|
9207
|
-
kind: z21.enum(["app", "workflow"]),
|
|
9208
|
-
name: z21.string().min(1).max(100),
|
|
9209
|
-
title: z21.string().max(200).optional(),
|
|
9210
|
-
icon: z21.enum(APP_ICON_NAMES5).optional(),
|
|
9211
|
-
source: z21.string().max(5 * 1024 * 1024),
|
|
9212
|
-
files: Files.optional()
|
|
9213
|
-
}),
|
|
9214
|
-
response: {
|
|
9215
|
-
201: Outcome,
|
|
9216
|
-
400: ErrorSchema,
|
|
9217
|
-
403: ErrorSchema,
|
|
9218
|
-
404: ErrorSchema,
|
|
9219
|
-
409: ErrorSchema,
|
|
9220
|
-
503: ErrorSchema
|
|
9221
|
-
}
|
|
9222
|
-
},
|
|
9223
|
-
handler: async (request, reply) => {
|
|
9224
|
-
if (!ctx.core || request.body.kind === "app" && !ctx.core.apps)
|
|
9225
|
-
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
9226
|
-
const identity = resolveIdentity(request);
|
|
9227
|
-
const artifact = await ctx.core.sessionArtifacts.create({
|
|
9228
|
-
...request.params,
|
|
9229
|
-
...request.body,
|
|
9230
|
-
identity
|
|
9231
|
-
});
|
|
9232
|
-
const build = artifact.appName && ctx.core.apps ? await ctx.core.apps.build({
|
|
9233
|
-
identity,
|
|
9234
|
-
projectId: artifact.projectId,
|
|
9235
|
-
appName: artifact.appName,
|
|
9236
|
-
artifactId: artifact.id,
|
|
9237
|
-
kind: "preview"
|
|
9238
|
-
}) : null;
|
|
9239
|
-
if (artifact.appName && request.body.icon && ctx.core.apps)
|
|
9240
|
-
await ctx.core.apps.updatePresentation({
|
|
9241
|
-
identity,
|
|
9242
|
-
projectId: artifact.projectId,
|
|
9243
|
-
appName: artifact.appName,
|
|
9244
|
-
icon: request.body.icon
|
|
9245
|
-
});
|
|
9246
|
-
return reply.status(201).send({ artifact, build });
|
|
9247
|
-
}
|
|
9248
|
-
});
|
|
9249
|
-
typed.route({
|
|
9250
|
-
method: "GET",
|
|
9251
|
-
url: "/projects/:projectId/session-artifacts/:artifactId",
|
|
9252
|
-
schema: {
|
|
9253
|
-
params: ArtifactParams,
|
|
9254
|
-
response: {
|
|
9255
|
-
200: SessionArtifactSchema,
|
|
9256
|
-
400: ErrorSchema,
|
|
9257
|
-
403: ErrorSchema,
|
|
9258
|
-
404: ErrorSchema,
|
|
9259
|
-
409: ErrorSchema,
|
|
9260
|
-
503: ErrorSchema
|
|
9261
|
-
}
|
|
9262
|
-
},
|
|
9263
|
-
handler: async (request, reply) => {
|
|
9264
|
-
if (!ctx.core)
|
|
9265
|
-
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
9266
|
-
try {
|
|
9267
|
-
return await ctx.core.sessionArtifacts.get({
|
|
9268
|
-
...request.params,
|
|
9269
|
-
identity: resolveIdentity(request)
|
|
9270
|
-
});
|
|
9271
|
-
} catch (error) {
|
|
9272
|
-
if (error instanceof SessionArtifactNotFoundError)
|
|
9273
|
-
return reply.status(404).send({ error: error.message });
|
|
9274
|
-
throw error;
|
|
9275
|
-
}
|
|
9276
|
-
}
|
|
9277
|
-
});
|
|
9278
|
-
typed.route({
|
|
9279
|
-
method: "GET",
|
|
9280
|
-
url: "/projects/:projectId/session-artifacts/:artifactId/files",
|
|
9281
|
-
schema: {
|
|
9282
|
-
params: ArtifactParams,
|
|
9283
|
-
response: {
|
|
9284
|
-
200: z21.record(z21.string(), z21.string()),
|
|
9285
|
-
400: ErrorSchema,
|
|
9286
|
-
403: ErrorSchema,
|
|
9287
|
-
404: ErrorSchema,
|
|
9288
|
-
409: ErrorSchema,
|
|
9289
|
-
503: ErrorSchema
|
|
9290
|
-
}
|
|
9291
|
-
},
|
|
9292
|
-
handler: async (request, reply) => {
|
|
9293
|
-
if (!ctx.core)
|
|
9294
|
-
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
9295
|
-
return ctx.core.sessionArtifacts.files({
|
|
9296
|
-
...request.params,
|
|
9297
|
-
identity: resolveIdentity(request)
|
|
9298
|
-
});
|
|
9299
|
-
}
|
|
9300
|
-
});
|
|
9301
|
-
typed.route({
|
|
9302
|
-
method: "PATCH",
|
|
9303
|
-
url: "/projects/:projectId/session-artifacts/:artifactId",
|
|
9304
|
-
bodyLimit: 6 * 1024 * 1024,
|
|
9305
|
-
schema: {
|
|
9306
|
-
params: ArtifactParams,
|
|
9307
|
-
body: z21.object({
|
|
9308
|
-
revision: z21.number().int().positive(),
|
|
9309
|
-
title: z21.string().max(200).optional(),
|
|
9310
|
-
files: z21.record(z21.string().min(1).max(512), z21.string().nullable())
|
|
9311
|
-
}),
|
|
9312
|
-
response: {
|
|
9313
|
-
200: Outcome,
|
|
9314
|
-
400: ErrorSchema,
|
|
9315
|
-
403: ErrorSchema,
|
|
9316
|
-
404: ErrorSchema,
|
|
9317
|
-
409: ErrorSchema,
|
|
9318
|
-
503: ErrorSchema
|
|
9319
|
-
}
|
|
9320
|
-
},
|
|
9321
|
-
handler: async (request, reply) => {
|
|
9322
|
-
if (!ctx.core)
|
|
9323
|
-
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
9324
|
-
const identity = resolveIdentity(request);
|
|
9325
|
-
const artifact = await ctx.core.sessionArtifacts.update({
|
|
9326
|
-
...request.params,
|
|
9327
|
-
...request.body,
|
|
9328
|
-
identity
|
|
9329
|
-
});
|
|
9330
|
-
const build = artifact.appName && ctx.core.apps ? await ctx.core.apps.build({
|
|
9331
|
-
identity,
|
|
9332
|
-
projectId: artifact.projectId,
|
|
9333
|
-
appName: artifact.appName,
|
|
9334
|
-
artifactId: artifact.id,
|
|
9335
|
-
kind: "preview"
|
|
9336
|
-
}) : null;
|
|
9337
|
-
return { artifact, build };
|
|
9338
|
-
}
|
|
9339
|
-
});
|
|
9340
|
-
typed.route({
|
|
9341
|
-
method: "DELETE",
|
|
9342
|
-
url: "/projects/:projectId/session-artifacts/:artifactId",
|
|
9343
|
-
schema: {
|
|
9344
|
-
params: ArtifactParams,
|
|
9345
|
-
response: {
|
|
9346
|
-
204: z21.null(),
|
|
9347
|
-
400: ErrorSchema,
|
|
9348
|
-
403: ErrorSchema,
|
|
9349
|
-
404: ErrorSchema,
|
|
9350
|
-
409: ErrorSchema,
|
|
9351
|
-
503: ErrorSchema
|
|
9352
|
-
}
|
|
9353
|
-
},
|
|
9354
|
-
handler: async (request, reply) => {
|
|
9355
|
-
if (!ctx.core)
|
|
9356
|
-
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
9357
|
-
const identity = resolveIdentity(request);
|
|
9358
|
-
const artifact = await ctx.core.sessionArtifacts.discard({
|
|
9359
|
-
...request.params,
|
|
9360
|
-
identity
|
|
9361
|
-
});
|
|
9362
|
-
if (artifact.sessionId && ctx.core.watchers)
|
|
9363
|
-
await ctx.core.watchers.stop({
|
|
9364
|
-
identity,
|
|
9365
|
-
projectId: artifact.projectId,
|
|
9366
|
-
sessionId: artifact.sessionId,
|
|
9367
|
-
watcherId: artifact.id
|
|
9368
|
-
});
|
|
9369
|
-
return reply.status(204).send(null);
|
|
9370
|
-
}
|
|
9371
|
-
});
|
|
9372
|
-
typed.route({
|
|
9373
|
-
method: "POST",
|
|
9374
|
-
url: "/projects/:projectId/session-artifacts/:artifactId/runs",
|
|
9375
|
-
schema: {
|
|
9376
|
-
params: ArtifactParams,
|
|
9377
|
-
body: TriggerRunSchema.extend({ environment: z21.string().optional() }),
|
|
9378
|
-
response: {
|
|
9379
|
-
201: RunSchema,
|
|
9380
|
-
400: ErrorSchema,
|
|
9381
|
-
403: ErrorSchema,
|
|
9382
|
-
404: ErrorSchema,
|
|
9383
|
-
409: ErrorSchema,
|
|
9384
|
-
503: ErrorSchema
|
|
9385
|
-
}
|
|
9386
|
-
},
|
|
9387
|
-
handler: async (request, reply) => {
|
|
9388
|
-
if (!ctx.core)
|
|
9389
|
-
return reply.status(503).send({ error: "Artifacts are unavailable" });
|
|
9390
|
-
const identity = resolveIdentity(request);
|
|
9391
|
-
const artifact = await ctx.core.sessionArtifacts.get({
|
|
9392
|
-
...request.params,
|
|
9393
|
-
identity
|
|
9394
|
-
});
|
|
9395
|
-
if (artifact.kind !== "workflow")
|
|
9396
|
-
return reply.status(400).send({ error: "This artifact is an app" });
|
|
9397
|
-
await ctx.core.sessionArtifacts.assertActive({
|
|
9398
|
-
...request.params,
|
|
9399
|
-
identity
|
|
9400
|
-
});
|
|
9401
|
-
const run = await ctx.core.runs.triggerAtCommit({
|
|
9402
|
-
...request.body,
|
|
9403
|
-
identity,
|
|
9404
|
-
projectId: artifact.projectId,
|
|
9405
|
-
workflowName: artifact.name,
|
|
9406
|
-
commitSha: artifact.commitSha,
|
|
9407
|
-
remoteBranch: artifact.remoteBranch
|
|
9408
|
-
});
|
|
9409
|
-
return reply.status(201).send(run);
|
|
9410
|
-
}
|
|
9411
|
-
});
|
|
9886
|
+
throw args.error;
|
|
9412
9887
|
}
|
|
9413
9888
|
|
|
9414
9889
|
// src/routes/session-mailboxes.ts
|
|
@@ -9470,9 +9945,9 @@ import {
|
|
|
9470
9945
|
// src/routes/session-terminals.ts
|
|
9471
9946
|
import {
|
|
9472
9947
|
AgentSessionNotFoundError as AgentSessionNotFoundError2,
|
|
9473
|
-
EnvironmentBindingUnavailableError as
|
|
9948
|
+
EnvironmentBindingUnavailableError as EnvironmentBindingUnavailableError5,
|
|
9474
9949
|
EnvironmentCapacityError as EnvironmentCapacityError4,
|
|
9475
|
-
EnvironmentNotFoundError as
|
|
9950
|
+
EnvironmentNotFoundError as EnvironmentNotFoundError5,
|
|
9476
9951
|
SessionTerminalNotFoundError,
|
|
9477
9952
|
SessionTerminalSecretsError,
|
|
9478
9953
|
SessionWorkspaceUnavailableError
|
|
@@ -9487,7 +9962,7 @@ function workspaceRefusal(reply, error) {
|
|
|
9487
9962
|
return reply.status(409).send({ error: error.message, code: error.reason });
|
|
9488
9963
|
if (error instanceof EnvironmentCapacityError4)
|
|
9489
9964
|
return reply.status(409).send({ error: error.message, code: "environment_full" });
|
|
9490
|
-
if (error instanceof
|
|
9965
|
+
if (error instanceof EnvironmentBindingUnavailableError5 || error instanceof EnvironmentNotFoundError5)
|
|
9491
9966
|
return reply.status(409).send({ error: error.message, code: "environment_unavailable" });
|
|
9492
9967
|
return;
|
|
9493
9968
|
}
|
|
@@ -9837,13 +10312,13 @@ import {
|
|
|
9837
10312
|
WebhookRejectedError,
|
|
9838
10313
|
WebhookTooLargeError
|
|
9839
10314
|
} from "@catamorphic/core";
|
|
9840
|
-
import { z as
|
|
9841
|
-
var WebhookSchema =
|
|
9842
|
-
name:
|
|
9843
|
-
url:
|
|
9844
|
-
workflows:
|
|
9845
|
-
listening:
|
|
9846
|
-
verified:
|
|
10315
|
+
import { z as z24 } from "zod";
|
|
10316
|
+
var WebhookSchema = z24.object({
|
|
10317
|
+
name: z24.string(),
|
|
10318
|
+
url: z24.string(),
|
|
10319
|
+
workflows: z24.array(z24.string()),
|
|
10320
|
+
listening: z24.boolean(),
|
|
10321
|
+
verified: z24.boolean()
|
|
9847
10322
|
});
|
|
9848
10323
|
function registerWebhookRoutes(app, ctx) {
|
|
9849
10324
|
const typed = app.withTypeProvider();
|
|
@@ -9858,14 +10333,14 @@ function registerWebhookRoutes(app, ctx) {
|
|
|
9858
10333
|
config: { public: true },
|
|
9859
10334
|
bodyLimit: hostMaxBytes,
|
|
9860
10335
|
schema: {
|
|
9861
|
-
params:
|
|
9862
|
-
projectId:
|
|
9863
|
-
name:
|
|
9864
|
-
token:
|
|
10336
|
+
params: z24.object({
|
|
10337
|
+
projectId: z24.string().uuid(),
|
|
10338
|
+
name: z24.string().min(1).max(63),
|
|
10339
|
+
token: z24.string().min(1).max(200)
|
|
9865
10340
|
}),
|
|
9866
10341
|
response: {
|
|
9867
|
-
200:
|
|
9868
|
-
202:
|
|
10342
|
+
200: z24.string(),
|
|
10343
|
+
202: z24.object({ id: z24.string(), duplicate: z24.boolean() }),
|
|
9869
10344
|
401: ErrorSchema,
|
|
9870
10345
|
404: ErrorSchema,
|
|
9871
10346
|
405: ErrorSchema,
|
|
@@ -9907,7 +10382,7 @@ function registerWebhookRoutes(app, ctx) {
|
|
|
9907
10382
|
url: "/projects/:projectId/webhooks",
|
|
9908
10383
|
schema: {
|
|
9909
10384
|
params: ProjectIdParamsSchema,
|
|
9910
|
-
response: { 200:
|
|
10385
|
+
response: { 200: z24.array(WebhookSchema), 503: ErrorSchema }
|
|
9911
10386
|
},
|
|
9912
10387
|
handler: async (request, reply) => {
|
|
9913
10388
|
const webhooks = ctx.core?.webhooks;
|
|
@@ -9928,7 +10403,7 @@ function registerWebhookRoutes(app, ctx) {
|
|
|
9928
10403
|
method: "POST",
|
|
9929
10404
|
url: "/projects/:projectId/webhooks/:name/rotate",
|
|
9930
10405
|
schema: {
|
|
9931
|
-
params: ProjectIdParamsSchema.extend({ name:
|
|
10406
|
+
params: ProjectIdParamsSchema.extend({ name: z24.string().min(1) }),
|
|
9932
10407
|
response: { 200: WebhookSchema, 404: ErrorSchema, 503: ErrorSchema }
|
|
9933
10408
|
},
|
|
9934
10409
|
handler: async (request, reply) => {
|
|
@@ -9959,269 +10434,6 @@ function queryValues(query) {
|
|
|
9959
10434
|
}));
|
|
9960
10435
|
}
|
|
9961
10436
|
|
|
9962
|
-
// src/routes/workflow-enablements.ts
|
|
9963
|
-
import {
|
|
9964
|
-
AccessDeniedError as AccessDeniedError9,
|
|
9965
|
-
AuthenticationRequiredError as AuthenticationRequiredError4,
|
|
9966
|
-
ConnectionPermissionDeniedError as ConnectionPermissionDeniedError3,
|
|
9967
|
-
ConnectionUnavailableError as ConnectionUnavailableError3,
|
|
9968
|
-
EnvironmentAccessDeniedError as EnvironmentAccessDeniedError4,
|
|
9969
|
-
EnvironmentBindingUnavailableError as EnvironmentBindingUnavailableError5,
|
|
9970
|
-
EnvironmentIncompatibleError as EnvironmentIncompatibleError4,
|
|
9971
|
-
EnvironmentNotFoundError as EnvironmentNotFoundError5,
|
|
9972
|
-
EnvironmentPolicyInvalidError,
|
|
9973
|
-
ProductionDeploymentNotFoundError as ProductionDeploymentNotFoundError3,
|
|
9974
|
-
WorkflowEnablementConflictError,
|
|
9975
|
-
WorkflowEnablementConsentRequiredError,
|
|
9976
|
-
WorkflowEnablementNotFoundError,
|
|
9977
|
-
WorkflowEnablementSuspendedError,
|
|
9978
|
-
WorkflowNotFoundError as WorkflowNotFoundError2
|
|
9979
|
-
} from "@catamorphic/core";
|
|
9980
|
-
import { z as z23 } from "zod";
|
|
9981
|
-
var EnablementParamsSchema = ProjectIdParamsSchema.extend({
|
|
9982
|
-
enablementId: z23.string().uuid()
|
|
9983
|
-
});
|
|
9984
|
-
var NotPublishedErrorSchema = z23.object({
|
|
9985
|
-
error: z23.string(),
|
|
9986
|
-
reason: z23.literal("not_published")
|
|
9987
|
-
});
|
|
9988
|
-
var PreviewConflictSchema = z23.union([NotPublishedErrorSchema, ErrorSchema]);
|
|
9989
|
-
var SelectionSchema = z23.record(z23.string(), z23.string().uuid()).optional();
|
|
9990
|
-
var PreviewBodySchema = z23.object({
|
|
9991
|
-
workflowName: z23.string().min(1),
|
|
9992
|
-
environment: z23.string().min(1).optional(),
|
|
9993
|
-
owner: WorkflowEnablementOwnerSchema.optional(),
|
|
9994
|
-
connectionSelections: SelectionSchema
|
|
9995
|
-
});
|
|
9996
|
-
function registerWorkflowEnablementRoutes(app, ctx) {
|
|
9997
|
-
const typed = app.withTypeProvider();
|
|
9998
|
-
const service = () => ctx.core?.workflowEnablements;
|
|
9999
|
-
typed.route({
|
|
10000
|
-
method: "GET",
|
|
10001
|
-
url: "/projects/:projectId/workflow-enablements",
|
|
10002
|
-
schema: {
|
|
10003
|
-
params: ProjectIdParamsSchema,
|
|
10004
|
-
querystring: z23.object({ workflowName: z23.string().optional() }),
|
|
10005
|
-
response: {
|
|
10006
|
-
200: z23.object({
|
|
10007
|
-
items: z23.array(WorkflowEnablementSchema),
|
|
10008
|
-
canManageProjectAutomations: z23.boolean()
|
|
10009
|
-
}),
|
|
10010
|
-
503: ErrorSchema
|
|
10011
|
-
}
|
|
10012
|
-
},
|
|
10013
|
-
handler: async (request, reply) => {
|
|
10014
|
-
const workflowEnablements = service();
|
|
10015
|
-
if (!workflowEnablements) {
|
|
10016
|
-
return reply.status(503).send({ error: "Workflow enablements unavailable" });
|
|
10017
|
-
}
|
|
10018
|
-
const identity = resolveIdentity(request);
|
|
10019
|
-
const { projectId } = request.params;
|
|
10020
|
-
return reply.send({
|
|
10021
|
-
items: await workflowEnablements.list({
|
|
10022
|
-
identity,
|
|
10023
|
-
projectId,
|
|
10024
|
-
workflowName: request.query.workflowName
|
|
10025
|
-
}),
|
|
10026
|
-
canManageProjectAutomations: workflowEnablements.mayManageProjectAutomations({
|
|
10027
|
-
identity,
|
|
10028
|
-
projectId
|
|
10029
|
-
})
|
|
10030
|
-
});
|
|
10031
|
-
}
|
|
10032
|
-
});
|
|
10033
|
-
typed.route({
|
|
10034
|
-
method: "POST",
|
|
10035
|
-
url: "/projects/:projectId/workflow-enablement-preview",
|
|
10036
|
-
schema: {
|
|
10037
|
-
params: ProjectIdParamsSchema,
|
|
10038
|
-
body: PreviewBodySchema,
|
|
10039
|
-
response: {
|
|
10040
|
-
200: WorkflowEnablementPreviewSchema,
|
|
10041
|
-
403: ErrorSchema,
|
|
10042
|
-
409: PreviewConflictSchema,
|
|
10043
|
-
428: AuthenticationRequiredSchema,
|
|
10044
|
-
503: ErrorSchema
|
|
10045
|
-
}
|
|
10046
|
-
},
|
|
10047
|
-
handler: async (request, reply) => {
|
|
10048
|
-
const workflowEnablements = service();
|
|
10049
|
-
if (!workflowEnablements) {
|
|
10050
|
-
return reply.status(503).send({ error: "Workflow enablements unavailable" });
|
|
10051
|
-
}
|
|
10052
|
-
try {
|
|
10053
|
-
return reply.send(await workflowEnablements.preview({
|
|
10054
|
-
identity: resolveIdentity(request),
|
|
10055
|
-
projectId: request.params.projectId,
|
|
10056
|
-
...request.body
|
|
10057
|
-
}));
|
|
10058
|
-
} catch (error) {
|
|
10059
|
-
return handleEnablementError(error, reply);
|
|
10060
|
-
}
|
|
10061
|
-
}
|
|
10062
|
-
});
|
|
10063
|
-
typed.route({
|
|
10064
|
-
method: "POST",
|
|
10065
|
-
url: "/projects/:projectId/workflow-enablements",
|
|
10066
|
-
schema: {
|
|
10067
|
-
params: ProjectIdParamsSchema,
|
|
10068
|
-
body: PreviewBodySchema.extend({ consentDigest: z23.string().length(64) }),
|
|
10069
|
-
response: {
|
|
10070
|
-
201: WorkflowEnablementSchema,
|
|
10071
|
-
403: ErrorSchema,
|
|
10072
|
-
409: PreviewConflictSchema,
|
|
10073
|
-
428: AuthenticationRequiredSchema,
|
|
10074
|
-
503: ErrorSchema
|
|
10075
|
-
}
|
|
10076
|
-
},
|
|
10077
|
-
handler: async (request, reply) => {
|
|
10078
|
-
const workflowEnablements = service();
|
|
10079
|
-
if (!workflowEnablements) {
|
|
10080
|
-
return reply.status(503).send({ error: "Workflow enablements unavailable" });
|
|
10081
|
-
}
|
|
10082
|
-
try {
|
|
10083
|
-
return reply.status(201).send(await workflowEnablements.create({
|
|
10084
|
-
identity: resolveIdentity(request),
|
|
10085
|
-
projectId: request.params.projectId,
|
|
10086
|
-
...request.body
|
|
10087
|
-
}));
|
|
10088
|
-
} catch (error) {
|
|
10089
|
-
return handleEnablementError(error, reply);
|
|
10090
|
-
}
|
|
10091
|
-
}
|
|
10092
|
-
});
|
|
10093
|
-
typed.route({
|
|
10094
|
-
method: "GET",
|
|
10095
|
-
url: "/projects/:projectId/workflow-enablements/:enablementId",
|
|
10096
|
-
schema: {
|
|
10097
|
-
params: EnablementParamsSchema,
|
|
10098
|
-
response: {
|
|
10099
|
-
200: WorkflowEnablementSchema,
|
|
10100
|
-
403: ErrorSchema,
|
|
10101
|
-
404: ErrorSchema
|
|
10102
|
-
}
|
|
10103
|
-
},
|
|
10104
|
-
handler: async (request, reply) => {
|
|
10105
|
-
const workflowEnablements = service();
|
|
10106
|
-
if (!workflowEnablements) {
|
|
10107
|
-
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
10108
|
-
}
|
|
10109
|
-
try {
|
|
10110
|
-
const result = await workflowEnablements.get({
|
|
10111
|
-
identity: resolveIdentity(request),
|
|
10112
|
-
enablementId: request.params.enablementId
|
|
10113
|
-
});
|
|
10114
|
-
return result.projectId === request.params.projectId ? reply.send(result) : reply.status(404).send({ error: "Workflow enablement not found" });
|
|
10115
|
-
} catch (error) {
|
|
10116
|
-
return handleEnablementError(error, reply);
|
|
10117
|
-
}
|
|
10118
|
-
}
|
|
10119
|
-
});
|
|
10120
|
-
for (const action of ["disable", "reenable"]) {
|
|
10121
|
-
typed.route({
|
|
10122
|
-
method: "POST",
|
|
10123
|
-
url: `/projects/:projectId/workflow-enablements/:enablementId/${action}`,
|
|
10124
|
-
schema: {
|
|
10125
|
-
params: EnablementParamsSchema,
|
|
10126
|
-
response: {
|
|
10127
|
-
200: WorkflowEnablementSchema,
|
|
10128
|
-
403: ErrorSchema,
|
|
10129
|
-
404: ErrorSchema,
|
|
10130
|
-
409: PreviewConflictSchema
|
|
10131
|
-
}
|
|
10132
|
-
},
|
|
10133
|
-
handler: async (request, reply) => {
|
|
10134
|
-
const workflowEnablements = service();
|
|
10135
|
-
if (!workflowEnablements) {
|
|
10136
|
-
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
10137
|
-
}
|
|
10138
|
-
try {
|
|
10139
|
-
const identity = resolveIdentity(request);
|
|
10140
|
-
const current = await workflowEnablements.get({
|
|
10141
|
-
identity,
|
|
10142
|
-
enablementId: request.params.enablementId
|
|
10143
|
-
});
|
|
10144
|
-
if (current.projectId !== request.params.projectId) {
|
|
10145
|
-
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
10146
|
-
}
|
|
10147
|
-
const result = await workflowEnablements[action]({
|
|
10148
|
-
identity,
|
|
10149
|
-
enablementId: request.params.enablementId
|
|
10150
|
-
});
|
|
10151
|
-
return reply.send(result);
|
|
10152
|
-
} catch (error) {
|
|
10153
|
-
return handleEnablementError(error, reply);
|
|
10154
|
-
}
|
|
10155
|
-
}
|
|
10156
|
-
});
|
|
10157
|
-
}
|
|
10158
|
-
typed.route({
|
|
10159
|
-
method: "POST",
|
|
10160
|
-
url: "/projects/:projectId/workflow-enablements/:enablementId/update-deployment",
|
|
10161
|
-
schema: {
|
|
10162
|
-
params: EnablementParamsSchema,
|
|
10163
|
-
body: z23.object({ consentDigest: z23.string().length(64) }),
|
|
10164
|
-
response: {
|
|
10165
|
-
200: WorkflowEnablementSchema,
|
|
10166
|
-
403: ErrorSchema,
|
|
10167
|
-
404: ErrorSchema,
|
|
10168
|
-
409: PreviewConflictSchema,
|
|
10169
|
-
428: AuthenticationRequiredSchema
|
|
10170
|
-
}
|
|
10171
|
-
},
|
|
10172
|
-
handler: async (request, reply) => {
|
|
10173
|
-
const workflowEnablements = service();
|
|
10174
|
-
if (!workflowEnablements) {
|
|
10175
|
-
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
10176
|
-
}
|
|
10177
|
-
try {
|
|
10178
|
-
const identity = resolveIdentity(request);
|
|
10179
|
-
const current = await workflowEnablements.get({
|
|
10180
|
-
identity,
|
|
10181
|
-
enablementId: request.params.enablementId
|
|
10182
|
-
});
|
|
10183
|
-
if (current.projectId !== request.params.projectId) {
|
|
10184
|
-
return reply.status(404).send({ error: "Workflow enablement not found" });
|
|
10185
|
-
}
|
|
10186
|
-
const result = await workflowEnablements.updateDeployment({
|
|
10187
|
-
identity,
|
|
10188
|
-
enablementId: request.params.enablementId,
|
|
10189
|
-
consentDigest: request.body.consentDigest
|
|
10190
|
-
});
|
|
10191
|
-
return reply.send(result);
|
|
10192
|
-
} catch (error) {
|
|
10193
|
-
return handleEnablementError(error, reply);
|
|
10194
|
-
}
|
|
10195
|
-
}
|
|
10196
|
-
});
|
|
10197
|
-
}
|
|
10198
|
-
function handleEnablementError(error, reply) {
|
|
10199
|
-
if (error instanceof AuthenticationRequiredError4) {
|
|
10200
|
-
return reply.status(428).send({
|
|
10201
|
-
error: error.message,
|
|
10202
|
-
code: "authentication_required",
|
|
10203
|
-
environment: error.environment,
|
|
10204
|
-
requirements: error.requirements
|
|
10205
|
-
});
|
|
10206
|
-
}
|
|
10207
|
-
if (error instanceof WorkflowEnablementNotFoundError) {
|
|
10208
|
-
return reply.status(404).send({ error: error.message });
|
|
10209
|
-
}
|
|
10210
|
-
if (error instanceof WorkflowNotFoundError2 || error instanceof ProductionDeploymentNotFoundError3) {
|
|
10211
|
-
return reply.status(409).send({
|
|
10212
|
-
error: "This workflow isn't in the project's published version yet. Publish the project's changes, then turn it on.",
|
|
10213
|
-
reason: "not_published"
|
|
10214
|
-
});
|
|
10215
|
-
}
|
|
10216
|
-
if (error instanceof AccessDeniedError9 || error instanceof ConnectionPermissionDeniedError3 || error instanceof EnvironmentAccessDeniedError4) {
|
|
10217
|
-
return reply.status(403).send({ error: error.message });
|
|
10218
|
-
}
|
|
10219
|
-
if (error instanceof WorkflowEnablementConsentRequiredError || error instanceof WorkflowEnablementConflictError || error instanceof ConnectionUnavailableError3 || error instanceof EnvironmentNotFoundError5 || error instanceof EnvironmentPolicyInvalidError || error instanceof EnvironmentIncompatibleError4 || error instanceof EnvironmentBindingUnavailableError5 || error instanceof WorkflowEnablementSuspendedError) {
|
|
10220
|
-
return reply.status(409).send({ error: error.message });
|
|
10221
|
-
}
|
|
10222
|
-
throw error;
|
|
10223
|
-
}
|
|
10224
|
-
|
|
10225
10437
|
// src/routes/workflows.ts
|
|
10226
10438
|
import {
|
|
10227
10439
|
ProjectNotFoundError as ProjectNotFoundError11,
|
|
@@ -10232,7 +10444,7 @@ import {
|
|
|
10232
10444
|
RunSignalNotFoundError,
|
|
10233
10445
|
WorkflowNotFoundError as WorkflowNotFoundError3
|
|
10234
10446
|
} from "@catamorphic/core";
|
|
10235
|
-
import { z as
|
|
10447
|
+
import { z as z25 } from "zod";
|
|
10236
10448
|
function registerWorkflowRoutes(app, ctx) {
|
|
10237
10449
|
const typed = app.withTypeProvider();
|
|
10238
10450
|
typed.route({
|
|
@@ -10469,7 +10681,7 @@ function registerWorkflowRoutes(app, ctx) {
|
|
|
10469
10681
|
body: CancelRunByKeySchema,
|
|
10470
10682
|
response: {
|
|
10471
10683
|
200: RunSchema,
|
|
10472
|
-
204:
|
|
10684
|
+
204: z25.null(),
|
|
10473
10685
|
404: ErrorSchema,
|
|
10474
10686
|
503: ErrorSchema
|
|
10475
10687
|
}
|
|
@@ -10593,6 +10805,7 @@ var catamorphicPlugin = async (app, opts) => {
|
|
|
10593
10805
|
registerWebhookRoutes(app, ctx);
|
|
10594
10806
|
registerAppRoutes(app, ctx);
|
|
10595
10807
|
registerSessionArtifactRoutes(app, ctx);
|
|
10808
|
+
registerPrivateCustomizationRoutes(app, ctx);
|
|
10596
10809
|
registerAppsMcpRoutes(app, ctx);
|
|
10597
10810
|
registerProjectMcpRoutes(app, ctx);
|
|
10598
10811
|
registerAgentCapabilityRoutes(app, ctx);
|
|
@@ -10664,7 +10877,7 @@ function createApp(config) {
|
|
|
10664
10877
|
import {
|
|
10665
10878
|
defineAgentCapability
|
|
10666
10879
|
} from "@catamorphic/core";
|
|
10667
|
-
import { z as
|
|
10880
|
+
import { z as z26 } from "zod";
|
|
10668
10881
|
var PUBLISHING_TOOLS = new Set([
|
|
10669
10882
|
"program_deploy",
|
|
10670
10883
|
"publish_document",
|
|
@@ -10675,11 +10888,11 @@ var OWN_CHAT_TOOLS = new Set([
|
|
|
10675
10888
|
"set_app_presentation",
|
|
10676
10889
|
"set_session_metadata"
|
|
10677
10890
|
]);
|
|
10678
|
-
var Definition =
|
|
10679
|
-
name:
|
|
10680
|
-
description:
|
|
10681
|
-
inputSchema:
|
|
10682
|
-
annotations:
|
|
10891
|
+
var Definition = z26.object({
|
|
10892
|
+
name: z26.string(),
|
|
10893
|
+
description: z26.string().default(""),
|
|
10894
|
+
inputSchema: z26.record(z26.string(), z26.unknown()),
|
|
10895
|
+
annotations: z26.object({ readOnlyHint: z26.boolean().optional() }).optional()
|
|
10683
10896
|
});
|
|
10684
10897
|
async function projectToolCapabilities(args) {
|
|
10685
10898
|
const { core, context } = args;
|
|
@@ -10714,8 +10927,8 @@ async function projectToolCapabilities(args) {
|
|
|
10714
10927
|
description: definition.description,
|
|
10715
10928
|
effect,
|
|
10716
10929
|
...PUBLISHING_TOOLS.has(definition.name) ? { sandboxing: "publish" } : OWN_CHAT_TOOLS.has(definition.name) ? { sandboxing: "contained" } : {},
|
|
10717
|
-
inputSchema:
|
|
10718
|
-
outputSchema:
|
|
10930
|
+
inputSchema: z26.fromJSONSchema(definition.inputSchema),
|
|
10931
|
+
outputSchema: z26.unknown(),
|
|
10719
10932
|
authorize: () => true,
|
|
10720
10933
|
beforeInvoke: (invocation, input) => args.beforeCall?.({
|
|
10721
10934
|
name: definition.name,
|
|
@@ -10725,7 +10938,7 @@ async function projectToolCapabilities(args) {
|
|
|
10725
10938
|
}) ?? Promise.resolve(),
|
|
10726
10939
|
execute: async (invocation, input) => {
|
|
10727
10940
|
invocation.signal?.throwIfAborted();
|
|
10728
|
-
const values =
|
|
10941
|
+
const values = z26.record(z26.string(), z26.unknown()).parse(input);
|
|
10729
10942
|
const owned = !taken.has(definition.name) && [
|
|
10730
10943
|
"session_artifact",
|
|
10731
10944
|
"create_watcher",
|
|
@@ -10734,13 +10947,13 @@ async function projectToolCapabilities(args) {
|
|
|
10734
10947
|
].includes(definition.name);
|
|
10735
10948
|
const result = await tool.call(owned ? { ...values, sessionId: context.sessionId } : values);
|
|
10736
10949
|
if (result.isError) {
|
|
10737
|
-
const content =
|
|
10950
|
+
const content = z26.array(z26.object({ text: z26.string() })).parse(result.content);
|
|
10738
10951
|
throw new Error(content.map((part) => part.text).join(`
|
|
10739
10952
|
`));
|
|
10740
10953
|
}
|
|
10741
10954
|
if (result.structuredContent !== undefined)
|
|
10742
10955
|
return JSON.parse(JSON.stringify(result.structuredContent));
|
|
10743
|
-
const content =
|
|
10956
|
+
const content = z26.array(z26.object({ text: z26.string() })).parse(result.content);
|
|
10744
10957
|
const text = content.map((part) => part.text).join(`
|
|
10745
10958
|
`);
|
|
10746
10959
|
try {
|
|
@@ -10917,5 +11130,5 @@ export {
|
|
|
10917
11130
|
serveSpaDist
|
|
10918
11131
|
};
|
|
10919
11132
|
|
|
10920
|
-
//# debugId=
|
|
11133
|
+
//# debugId=BDC9E1010DAF3A1B64756E2164756E21
|
|
10921
11134
|
//# sourceMappingURL=index.js.map
|