@engenty/wizards-runtime 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/agents/architect.js +4 -4
- package/apps/runtime/dist/agents/studio-assistant.js +2 -31
- package/apps/runtime/dist/app.js +4 -4
- package/apps/runtime/dist/assistant/knows.js +2 -2
- package/apps/runtime/dist/auth/index.js +1 -1
- package/apps/runtime/dist/authoring/example.js +1 -1
- package/apps/runtime/dist/authoring/guide.js +35 -6
- package/apps/runtime/dist/broker/account.js +85 -16
- package/apps/runtime/dist/broker/call.js +137 -37
- package/apps/runtime/dist/broker/log.js +19 -5
- package/apps/runtime/dist/broker/rwx.js +12 -9
- package/apps/runtime/dist/connectors/index.js +52 -11
- package/apps/runtime/dist/connectors/person-connections.js +279 -0
- package/apps/runtime/dist/connectors/person-sign-ins.js +74 -3
- package/apps/runtime/dist/connectors/same-service.js +14 -0
- package/apps/runtime/dist/connectors/space-choice.js +116 -0
- package/apps/runtime/dist/connectors/space-connections.js +40 -2
- package/apps/runtime/dist/db/client.js +8 -0
- package/apps/runtime/dist/db/kept-accounts.js +88 -0
- package/apps/runtime/dist/db/migrations/tenant/0075_person_connection.sql +25 -0
- package/apps/runtime/dist/db/migrations/tenant/0076_clients_in_spaces.sql +28 -0
- package/apps/runtime/dist/db/migrations/tenant/0077_client_spaces_at_root.sql +21 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0075_snapshot.json +7859 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0076_snapshot.json +7859 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0077_snapshot.json +7859 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +21 -0
- package/apps/runtime/dist/db/schema.js +67 -16
- package/apps/runtime/dist/docs/dev/api.md +8 -8
- package/apps/runtime/dist/docs/dev/wizard-format/index.md +3 -1
- package/apps/runtime/dist/elements/caller.js +1 -1
- package/apps/runtime/dist/elements/knowledge.js +5 -5
- package/apps/runtime/dist/elements/wizards.js +7 -11
- package/apps/runtime/dist/engine/notices.js +13 -1
- package/apps/runtime/dist/engine/requirements.js +116 -3
- package/apps/runtime/dist/engine/run-needs.js +58 -0
- package/apps/runtime/dist/engine/runner.js +229 -23
- package/apps/runtime/dist/engine/starts.js +9 -0
- package/apps/runtime/dist/engine/types.js +5 -1
- package/apps/runtime/dist/harness/claude.js +3 -1
- package/apps/runtime/dist/manage.js +1 -1
- package/apps/runtime/dist/mcp/tools.js +3 -3
- package/apps/runtime/dist/plugins/runs.js +2 -1
- package/apps/runtime/dist/prompts/architect.md +3 -3
- package/apps/runtime/dist/prompts/authoring.md +17 -6
- package/apps/runtime/dist/prompts/goose.md +0 -5
- package/apps/runtime/dist/routes/api.js +9 -4
- package/apps/runtime/dist/routes/client-contract.js +2 -2
- package/apps/runtime/dist/routes/client-spaces.js +1 -16
- package/apps/runtime/dist/routes/connections.js +6 -1
- package/apps/runtime/dist/routes/marketplace.js +27 -7
- package/apps/runtime/dist/routes/plugins.js +1 -1
- package/apps/runtime/dist/routes/runs.js +157 -11
- package/apps/runtime/dist/routes/studio.js +42 -5
- package/apps/runtime/dist/services/client-portal.js +58 -49
- package/apps/runtime/dist/services/client-spaces.js +57 -125
- package/apps/runtime/dist/services/links.js +3 -3
- package/apps/runtime/dist/services/marketplace.js +6 -2
- package/apps/runtime/dist/services/members-studio.js +1 -1
- package/apps/runtime/dist/services/query-vectors.js +1 -1
- package/apps/runtime/dist/services/runs.js +19 -20
- package/apps/runtime/dist/services/space-parent.js +4 -11
- package/apps/runtime/dist/services/spaces.js +56 -47
- package/apps/runtime/dist/services/work-ai.js +3 -3
- package/apps/runtime/dist/services/work-chats.js +14 -6
- package/apps/runtime/dist/sharing/state.js +7 -3
- package/apps/runtime/dist/store/index.js +28 -8
- package/apps/runtime/dist/store/shared-lists.js +2 -2
- package/apps/runtime/dist/sync/hub.js +9 -5
- package/apps/runtime/dist/tools/connector.js +4 -2
- package/apps/web/dist/assets/{AboutDialog-BxT7chz8.js → AboutDialog-QWzpEK8M.js} +1 -1
- package/apps/web/dist/assets/{BlockEditor-BX8ZxxIc.js → BlockEditor-C44bI_ih.js} +1 -1
- package/apps/web/dist/assets/{Bundle-Dkpi5E6W.js → Bundle-DZyQ1FP7.js} +1 -1
- package/apps/web/dist/assets/CapabilitiesPage-DAr0-gN1.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-j-vHLy-V.js → ChangelogDialog-CdHqJV2P.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-CfM2A-yS.js → CodeEditor-BRufUwu0.js} +1 -1
- package/apps/web/dist/assets/ConnectorsSection-BO6jHrYU.js +1 -0
- package/apps/web/dist/assets/EditorPage-Bx-fKnsY.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-E0kuvM5n.js → FlowPreview-aj58c-gH.js} +1 -1
- package/apps/web/dist/assets/{LangSwitch-DhQmCtyY.js → LangSwitch-BNkytlus.js} +1 -1
- package/apps/web/dist/assets/Marketplace-D3hdvrkz.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-fveQcQlY.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-BTX1g2t1.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-DwF6KdQy.js +1 -0
- package/apps/web/dist/assets/ProtocolSection-YnJcMN9E.js +1 -0
- package/apps/web/dist/assets/PublicRunner-Bp4DxTrD.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-CkToYpY5.js → ReadOnly-C6qmTD35.js} +1 -1
- package/apps/web/dist/assets/{Results-C9qxCpUQ.js → Results-BNuuBiwU.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-BRXH71U8.js → RunDrawer-CMgN-XTB.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-CuUB26YJ.js +2 -0
- package/apps/web/dist/assets/SetupPage-llGzMVeH.js +1 -0
- package/apps/web/dist/assets/{SharePage-Boj1R928.js → SharePage-CgQp_PT6.js} +1 -1
- package/apps/web/dist/assets/SkillEditor-ARx8QPGp.js +1 -0
- package/apps/web/dist/assets/Skills-frfXXEcF.js +9 -0
- package/apps/web/dist/assets/SpacePage-Dv6ocsc_.js +2 -0
- package/apps/web/dist/assets/StudioHome-B0bZRm1L.js +1 -0
- package/apps/web/dist/assets/TableEditor-CfzTLmJF.js +7 -0
- package/apps/web/dist/assets/{UpdateCheck-DFor0F9T.js → UpdateCheck-D3QhfI5c.js} +2 -2
- package/apps/web/dist/assets/{brand-Ij-I_Lms.js → brand-DKuVyYhH.js} +1 -1
- package/apps/web/dist/assets/changelog-Db3nvWao.js +1 -0
- package/apps/web/dist/assets/{code-editor-BVgSljQq.js → code-editor-BLwDuQLI.js} +2 -2
- package/apps/web/dist/assets/host-C-AAp8Bz.js +69 -0
- package/apps/web/dist/assets/i18n-Dyi0kvaA.js +55 -0
- package/apps/web/dist/assets/index-CduFlFCp.css +1 -0
- package/apps/web/dist/assets/index-CtE0rJEL.js +102 -0
- package/apps/web/dist/assets/{read-aloud-pd-PWi_5.js → read-aloud-DGS8mWgC.js} +1 -1
- package/apps/web/dist/assets/session-EIDP3Wzc.js +1 -0
- package/apps/web/dist/assets/theme-B46aPLtX.js +14 -0
- package/apps/web/dist/assets/ui-DSgksc1H.js +16 -0
- package/apps/web/dist/assets/{useMutation-CUZC19i3.js → useMutation-fT44ij_b.js} +1 -1
- package/apps/web/dist/assets/{viewers-D-8HZrcq.js → viewers-DvA5VsXw.js} +2 -2
- package/apps/web/dist/index.html +18 -13
- package/apps/web/dist/mcp/flow.html +62 -62
- package/node_modules/@engenty/wizards-shared/dist/catalog-prompt.js +2 -2
- package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +67 -0
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +10324 -7
- package/node_modules/@engenty/wizards-shared/dist/definition.js +32 -6
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +17 -23
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +17 -23
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
- package/node_modules/@engenty/wizards-shared/dist/marketplace-search.js +7 -1
- package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +9 -2
- package/node_modules/@engenty/wizards-shared/dist/page-data.d.ts +72 -0
- package/node_modules/@engenty/wizards-shared/dist/page-data.js +5 -0
- package/node_modules/@engenty/wizards-shared/dist/page-look.d.ts +17 -0
- package/node_modules/@engenty/wizards-shared/dist/page-look.js +118 -0
- package/node_modules/@engenty/wizards-shared/dist/page-styles.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/page-styles.js +98 -0
- package/node_modules/@engenty/wizards-shared/dist/page-texts.d.ts +36 -0
- package/node_modules/@engenty/wizards-shared/dist/page-texts.js +119 -0
- package/node_modules/@engenty/wizards-shared/dist/requires.js +2 -0
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +56 -1
- package/node_modules/@engenty/wizards-shared/dist/run.js +25 -0
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +27 -1
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +26 -0
- package/node_modules/@engenty/wizards-shared/dist/store.d.ts +24 -1
- package/node_modules/@engenty/wizards-shared/dist/transition.d.ts +2 -1
- package/node_modules/@engenty/wizards-shared/dist/transition.js +10 -2
- package/node_modules/@engenty/wizards-shared/dist/wizard-text.js +1 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/CapabilitiesPage-CfSb23wy.js +0 -2
- package/apps/web/dist/assets/ConnectorsSection-fRBZYfZu.js +0 -1
- package/apps/web/dist/assets/EditorPage-CrFyN_Qn.js +0 -3
- package/apps/web/dist/assets/Marketplace-BdkNOARm.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-BATgI9GR.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-B5V5ScKh.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-DWpDqlCi.js +0 -1
- package/apps/web/dist/assets/PreviewPane-Br2w92Wh.js +0 -7
- package/apps/web/dist/assets/ProtocolSection-DMCojdZu.js +0 -1
- package/apps/web/dist/assets/PublicRunner-Cjhfeqi3.js +0 -1
- package/apps/web/dist/assets/SettingsPage-Dobd7tAA.js +0 -2
- package/apps/web/dist/assets/SetupPage-BkMjwBlV.js +0 -1
- package/apps/web/dist/assets/SkillEditor-DtVRUYqS.js +0 -1
- package/apps/web/dist/assets/Skills-DK1Pv-Xh.js +0 -9
- package/apps/web/dist/assets/SpacePage-CjgBRkkw.js +0 -2
- package/apps/web/dist/assets/StudioHome-B5HcJJ4Q.js +0 -1
- package/apps/web/dist/assets/changelog-n9RARUzp.js +0 -1
- package/apps/web/dist/assets/host-BELYIPMT.js +0 -69
- package/apps/web/dist/assets/i18n-DPqdH1PJ.js +0 -55
- package/apps/web/dist/assets/index-CVZlO0z3.css +0 -1
- package/apps/web/dist/assets/index-wJZVaKLg.js +0 -10
- package/apps/web/dist/assets/runners-D9DHhaD9.js +0 -1
- package/apps/web/dist/assets/session-Mt-n8MI0.js +0 -1
- package/apps/web/dist/assets/theme-BQhQx_UL.js +0 -14
- package/apps/web/dist/assets/ui-D4qQLcbs.js +0 -16
|
@@ -18,12 +18,13 @@ import { authenticate, principalOf } from "../mcp/auth.js";
|
|
|
18
18
|
import { loadedPlugin, pluginIdsOf } from "../plugins/registry.js";
|
|
19
19
|
import { asRole, mayBuild, mayCreate } from "../services/access.js";
|
|
20
20
|
import { apiRun, apiRuns, apiSpaceDetails, apiSpaces, apiWizards } from "../services/api.js";
|
|
21
|
-
import { ServiceError } from "../services/errors.js";
|
|
21
|
+
import { notFound, ServiceError } from "../services/errors.js";
|
|
22
22
|
import { deleteFile, draftFiles, writeFile } from "../services/files.js";
|
|
23
23
|
import { asLang, searchMarketplace } from "../services/marketplace.js";
|
|
24
24
|
import { requireStudio } from "../services/members-studio.js";
|
|
25
25
|
import { exportWizard } from "../services/package.js";
|
|
26
26
|
import { siteJob, siteSchema, startSiteJob } from "../services/site.js";
|
|
27
|
+
import { keptFrom } from "../services/spaces.js";
|
|
27
28
|
import { checkOnServer, checkSchema, listSyncedSpaces, patchSyncedWizard, removeSyncedSpace, removeSyncedWizard, rotateSyncedLink, syncDataSchema, syncSettingsSchema, syncSpaceData, syncWizard, syncWizardSchema, } from "../services/synced-spaces.js";
|
|
28
29
|
import { createWizard, ownedWizard, publishWizard, writeDraft } from "../services/wizards.js";
|
|
29
30
|
import { adoptSpace, blobBytes, missingBlobs, publishSynced, pullChanges, pushChanges, rotateSynced, syncHears, syncOverview, takeBlob, } from "../sync/hub.js";
|
|
@@ -56,6 +57,10 @@ export const inTenantAs = async (who, fn) => {
|
|
|
56
57
|
*/
|
|
57
58
|
const inSpaceAs = (who, spaceId, fn) => inTenantAs(who, async () => {
|
|
58
59
|
await requireStudio("spaces", spaceId);
|
|
60
|
+
// Someone else's Mein Space, or a space for its members only, is not there for the caller.
|
|
61
|
+
if (await keptFrom(who.userId, spaceId)) {
|
|
62
|
+
throw notFound();
|
|
63
|
+
}
|
|
59
64
|
return fn();
|
|
60
65
|
});
|
|
61
66
|
const HOUR = 60 * 60 * 1000;
|
|
@@ -79,8 +84,8 @@ export async function caller(c, scopes, { clients = false } = {}) {
|
|
|
79
84
|
return authInfo;
|
|
80
85
|
}
|
|
81
86
|
const who = principalOf(authInfo);
|
|
82
|
-
// A client of the organization uses
|
|
83
|
-
// (docs/plans/
|
|
87
|
+
// A client of the organization uses the elements of their client spaces, nothing else
|
|
88
|
+
// of the API (docs/plans/org-spaces.md).
|
|
84
89
|
if (who.role === "client" && !clients) {
|
|
85
90
|
return c.json({ error: "This isn’t open to clients.", code: "forbidden" }, 403);
|
|
86
91
|
}
|
|
@@ -433,7 +438,7 @@ export const apiRoutes = new Hono()
|
|
|
433
438
|
if (who instanceof Response) {
|
|
434
439
|
return who;
|
|
435
440
|
}
|
|
436
|
-
return inTenantAs(who, async () => c.json(await syncOverview()));
|
|
441
|
+
return inTenantAs(who, async () => c.json(await syncOverview(who.userId)));
|
|
437
442
|
})
|
|
438
443
|
// What changed in the organization's spaces, as it happens: an install pulls those spaces now
|
|
439
444
|
// instead of at its next round (docs/plans/live-changes.md, 7).
|
|
@@ -16,7 +16,7 @@ export const CLIENT_CALLS = {
|
|
|
16
16
|
spaces: {
|
|
17
17
|
scope: "data:read",
|
|
18
18
|
space: false,
|
|
19
|
-
description: "Your client spaces, each with the
|
|
19
|
+
description: "Your client spaces, each with the organization's name and the brand it wears.",
|
|
20
20
|
input: none,
|
|
21
21
|
run: (who) => clientSpaces(who),
|
|
22
22
|
},
|
|
@@ -30,7 +30,7 @@ export const CLIENT_CALLS = {
|
|
|
30
30
|
wizards: {
|
|
31
31
|
scope: "elements:read",
|
|
32
32
|
space: true,
|
|
33
|
-
description: "The firm
|
|
33
|
+
description: "The wizards the firm opened to you in a client space, each with its engenty (`avatar`) and its number of steps.",
|
|
34
34
|
input: none,
|
|
35
35
|
run: (who, spaceId) => clientWizards(who, spaceId),
|
|
36
36
|
},
|
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { setOpenToClients } from "../broker/rwx.js";
|
|
4
|
-
import { addSpaceMember, clientOpenOf,
|
|
4
|
+
import { addSpaceMember, clientOpenOf, inviteClient, listSpaceMembers, removeSpaceMember, requireClientSpaces, shareWithClient, } from "../services/client-spaces.js";
|
|
5
5
|
const OPEN_KINDS = ["document", "table", "page", "wizard"];
|
|
6
6
|
export const clientSpaceRoutes = new Hono()
|
|
7
|
-
.get("/spaces/:id/clients", async (c) => c.json({ clients: await listClientSpaces(c.get("user").id, c.req.param("id")) }))
|
|
8
|
-
.post("/spaces/:id/clients", async (c) => {
|
|
9
|
-
const { name } = z.object({ name: z.string().min(1).max(200) }).parse(await c.req.json());
|
|
10
|
-
return c.json(await createClientSpace(c.get("user").id, c.req.param("id"), name));
|
|
11
|
-
})
|
|
12
|
-
.patch("/spaces/:id/client", async (c) => {
|
|
13
|
-
const { name } = z
|
|
14
|
-
.object({ name: z.string().trim().min(1).max(200) })
|
|
15
|
-
.parse(await c.req.json());
|
|
16
|
-
return c.json(await renameClientSpace(c.get("user").id, c.req.param("id"), name));
|
|
17
|
-
})
|
|
18
7
|
// A run of a client space shared with its clients on purpose, or taken back.
|
|
19
8
|
.put("/runs/:id/client-share", async (c) => {
|
|
20
9
|
const { shared } = z.object({ shared: z.boolean() }).parse(await c.req.json());
|
|
21
10
|
return c.json(await shareWithClient(c.get("user").id, c.req.param("id"), shared));
|
|
22
|
-
})
|
|
23
|
-
.delete("/spaces/:id/client", async (c) => {
|
|
24
|
-
await deleteClientSpace(c.get("user").id, c.req.param("id"));
|
|
25
|
-
return c.json({ ok: true });
|
|
26
11
|
})
|
|
27
12
|
.get("/spaces/:id/members", async (c) => c.json({ members: await listSpaceMembers(c.get("user").id, c.req.param("id")) }))
|
|
28
13
|
.put("/spaces/:id/members/:userId", async (c) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { inAudience } from "../broker/index.js";
|
|
4
|
-
import { namesOf } from "../connectors/person-sign-ins.js";
|
|
4
|
+
import { disconnectOwn, namesOf } from "../connectors/person-sign-ins.js";
|
|
5
5
|
import { connectionPatchSchema, createSpaceConnection, newConnectionSchema, pauseSpaceConnection, removeSignIn, removeSpaceConnection, signInWithCredentials, spaceConnectionViews, startSpaceConnectionOAuth, updateSpaceConnection, } from "../connectors/space-connections.js";
|
|
6
6
|
import { isAdminRole } from "../services/access.js";
|
|
7
7
|
import { ownedSpace } from "../services/spaces.js";
|
|
@@ -70,6 +70,11 @@ export const connectionRoutes = new Hono()
|
|
|
70
70
|
.delete("/connections/:id/my-sign-in", async (c) => {
|
|
71
71
|
await removeSignIn(c.req.param("id"), asMe(c.get("user")));
|
|
72
72
|
return c.json({ ok: true });
|
|
73
|
+
})
|
|
74
|
+
// One of the person's own connections (menu › „Verbindungen“): it goes with every choice naming it.
|
|
75
|
+
.delete("/my-connections/:id", async (c) => {
|
|
76
|
+
await disconnectOwn(c.get("user"), c.req.param("id"));
|
|
77
|
+
return c.json({ ok: true });
|
|
73
78
|
});
|
|
74
79
|
async function signIn(c, as) {
|
|
75
80
|
const body = signInSchema.parse(await c.req.json());
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { FORMAT_VERSIONS } from "@engenty/wizards-shared/definition";
|
|
1
2
|
import { CAPABILITY_IDS } from "@engenty/wizards-shared/fit";
|
|
2
3
|
import { INDUSTRY_IDS, ITEM_FORMAT_IDS, MARKETPLACE_PLAN_IDS, USE_CASE_IDS, } from "@engenty/wizards-shared/marketplace";
|
|
3
4
|
import { sectorOf } from "@engenty/wizards-shared/sectors";
|
|
4
5
|
import { Hono } from "hono";
|
|
5
6
|
import { z } from "zod";
|
|
7
|
+
import { feature, remoteFeatures } from "../features.js";
|
|
6
8
|
import { asLang, featuredFirst, marketplaceDetail, searchMarketplace, searchMarketplaceAsGuest, starEntry, } from "../services/marketplace.js";
|
|
7
9
|
import { byFit, organizationContext } from "../services/organization-context.js";
|
|
8
10
|
import { notFoundAnswer } from "./lang.js";
|
|
@@ -14,6 +16,7 @@ const searchSchema = z.object({
|
|
|
14
16
|
format: z.enum(ITEM_FORMAT_IDS).optional(),
|
|
15
17
|
capability: z.enum(CAPABILITY_IDS).optional(),
|
|
16
18
|
plan: z.enum(MARKETPLACE_PLAN_IDS).optional(),
|
|
19
|
+
version: z.enum(FORMAT_VERSIONS).optional(),
|
|
17
20
|
starred: z
|
|
18
21
|
.enum(["1", "0"])
|
|
19
22
|
.optional()
|
|
@@ -26,22 +29,33 @@ const searchSchema = z.object({
|
|
|
26
29
|
.optional()
|
|
27
30
|
.transform((v) => v === "1"),
|
|
28
31
|
});
|
|
32
|
+
/** The version of a wizard's format is offered while the kernel switch is on. */
|
|
33
|
+
const versionsOffered = async () => feature("kernel", await remoteFeatures().catch(() => null));
|
|
34
|
+
/** The filters' counts, without the versions of the format while those are not offered. */
|
|
35
|
+
const facetsShown = (facets, versions) => {
|
|
36
|
+
if (versions)
|
|
37
|
+
return facets;
|
|
38
|
+
const { version: _version, ...rest } = facets;
|
|
39
|
+
return rest;
|
|
40
|
+
};
|
|
29
41
|
/** The marketplace for someone signed in: the search on "new", an entry, and the stars. */
|
|
30
42
|
export const marketplaceStudio = new Hono()
|
|
31
43
|
.get("/", async (c) => {
|
|
32
|
-
const { lang, fit, ...
|
|
44
|
+
const { lang, fit, ...asked } = searchSchema.parse(c.req.query());
|
|
45
|
+
const versions = await versionsOffered();
|
|
46
|
+
const { version, ...rest } = asked;
|
|
47
|
+
const search = versions ? asked : rest;
|
|
33
48
|
const context = fit ? await organizationContext(c.get("user").tenantId) : null;
|
|
34
49
|
if (!context) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
context: null,
|
|
38
|
-
});
|
|
50
|
+
const found = featuredFirst(await searchMarketplace({ ...search, lang: asLang(lang) }), search);
|
|
51
|
+
return c.json({ ...found, facets: facetsShown(found.facets, versions), context: null });
|
|
39
52
|
}
|
|
40
53
|
// The whole catalog in the order that fits, then the page of it.
|
|
41
54
|
const all = featuredFirst(await searchMarketplace({ lang: asLang(lang), limit: 100, offset: 0 }), {});
|
|
42
55
|
const sector = sectorOf(context.sector);
|
|
43
56
|
return c.json({
|
|
44
57
|
...all,
|
|
58
|
+
facets: facetsShown(all.facets, versions),
|
|
45
59
|
entries: byFit(all.entries, context).slice(search.offset, search.offset + search.limit),
|
|
46
60
|
context: {
|
|
47
61
|
sector: sector?.id ?? null,
|
|
@@ -63,6 +77,12 @@ export const marketplaceStudio = new Hono()
|
|
|
63
77
|
});
|
|
64
78
|
/** The gallery for someone not signed in (the studio's start page for guests): only the search. */
|
|
65
79
|
export const marketplaceGuest = new Hono().get("/", async (c) => {
|
|
66
|
-
const { lang, starred: _starred, ...
|
|
67
|
-
|
|
80
|
+
const { lang, starred: _starred, ...asked } = searchSchema.parse(c.req.query());
|
|
81
|
+
const versions = await versionsOffered();
|
|
82
|
+
const { version: _version, ...rest } = asked;
|
|
83
|
+
const found = await searchMarketplaceAsGuest({
|
|
84
|
+
...(versions ? asked : rest),
|
|
85
|
+
lang: asLang(lang),
|
|
86
|
+
});
|
|
87
|
+
return c.json({ ...found, facets: facetsShown(found.facets, versions) });
|
|
68
88
|
});
|
|
@@ -54,7 +54,7 @@ export function answerOf(err) {
|
|
|
54
54
|
export async function dispatchAs(c, user) {
|
|
55
55
|
const id = c.req.param("id") ?? "";
|
|
56
56
|
const plugin = (await pluginIdsOf(user.tenantId)).has(id) ? loadedPlugin(id) : undefined;
|
|
57
|
-
// A client of the organization reaches no plugin's studio routes (docs/plans/
|
|
57
|
+
// A client of the organization reaches no plugin's studio routes (docs/plans/org-spaces.md).
|
|
58
58
|
if (!plugin || user.role === "client") {
|
|
59
59
|
return c.json(notFoundAnswer(c), 404);
|
|
60
60
|
}
|
|
@@ -15,9 +15,10 @@ import { principalOf } from "../auth/index.js";
|
|
|
15
15
|
import { keptStepIds } from "../broker/index.js";
|
|
16
16
|
import { MARK_FOCUSED_PERSONAL } from "../browser/snapshot.js";
|
|
17
17
|
import { clientOf, clientRefused } from "../clients.js";
|
|
18
|
-
import { ConnectError, connectionViews, connectWithCredentials, disconnect, findConnection, finishOAuth, oauthStateLang, oauthStateRun, startOAuth, } from "../connectors/index.js";
|
|
18
|
+
import { ConnectError, choose, connectionViews, connectorFor, connectWithCredentials, disconnect, findConnection, finishOAuth, oauthStateLang, oauthStateRun, startOAuth, } from "../connectors/index.js";
|
|
19
|
+
import { runConnectionsOn } from "../connectors/person-connections.js";
|
|
19
20
|
import { finishPluginOAuth, pluginStateTenant } from "../connectors/plugin-connections.js";
|
|
20
|
-
import { finishSpaceConnectionOAuth, spaceConnectionStateTenant, } from "../connectors/space-connections.js";
|
|
21
|
+
import { finishSpaceConnectionOAuth, signInWithCredentials, spaceConnectionForNeed, spaceConnectionOf, spaceConnectionStateTenant, spaceConnectorFor, startSpaceConnectionOAuth, } from "../connectors/space-connections.js";
|
|
21
22
|
import { db, schema, withTenant } from "../db/client.js";
|
|
22
23
|
import { answerersOf, answeringNarrowed, hiddenWhileAsked, mayAct, mayAnswerStep, mayGoBackFrom, mayWithdraw, stepOfRun, viewFor, } from "../engine/answerers.js";
|
|
23
24
|
import { answerAsk, pendingAsk } from "../engine/asks.js";
|
|
@@ -27,7 +28,7 @@ import { fieldErrorsIn } from "../engine/input.js";
|
|
|
27
28
|
import { fromOwner } from "../engine/owner.js";
|
|
28
29
|
import { pushAvailable, setPushDevice, setRunViewed } from "../engine/push.js";
|
|
29
30
|
import { liveResources } from "../engine/resources.js";
|
|
30
|
-
import { answerTurn, cancel, createRun, durableRunsOn, editOutput, GuestBudgetError, goBack, keepUnsent, NoCreditsError, RunConflict, RunInputError, retry, reviewStep, runView, spaceIdOf, stopRun, submitPage, talkAllowed, wakeNow, writeRunState, } from "../engine/runner.js";
|
|
31
|
+
import { answerTurn, cancel, createRun, durableRunsOn, editOutput, GuestBudgetError, goBack, keepUnsent, NoCreditsError, ownsRun, RunConflict, RunInputError, retry, reviewStep, runView, signedIn, spaceIdOf, stopRun, submitPage, talkAllowed, wakeNow, writeRunState, } from "../engine/runner.js";
|
|
31
32
|
import { basePath, env } from "../env.js";
|
|
32
33
|
import { loadAsset, saveAsset } from "../files/storage.js";
|
|
33
34
|
import { checkUpload } from "../files/upload-check.js";
|
|
@@ -40,7 +41,7 @@ import { errorText, ModelUnavailableError, noteOf } from "../model-errors.js";
|
|
|
40
41
|
import { listDownload, renderDownload, stepHtml } from "../render/downloads.js";
|
|
41
42
|
import { HTML_RESPONSE_CSP } from "../render/guard.js";
|
|
42
43
|
import { runTicketValid, runViewTicketValid, runWaitTicketValid, verifySignedUrl, } from "../secrets/signing.js";
|
|
43
|
-
import { isAdminRole, MEMBERS_EDIT_ONLY } from "../services/access.js";
|
|
44
|
+
import { asRole, isAdminRole, MEMBERS_EDIT_ONLY } from "../services/access.js";
|
|
44
45
|
import { brandView } from "../services/brand.js";
|
|
45
46
|
import { clientMayOpen } from "../services/client-portal.js";
|
|
46
47
|
import { ServiceError } from "../services/errors.js";
|
|
@@ -205,7 +206,7 @@ async function openedRun(c, runId, opts) {
|
|
|
205
206
|
}
|
|
206
207
|
const user = await principalOf(c);
|
|
207
208
|
if (user && user.tenantId === run.tenantId) {
|
|
208
|
-
// A client of the organization opens only the runs of their
|
|
209
|
+
// A client of the organization opens only the runs of their spaces that are theirs
|
|
209
210
|
// or shared with them (docs/plans/client-portal.md); the firm opens every run.
|
|
210
211
|
if (user.role === "client" && !(await clientMayOpen(user.id, run))) {
|
|
211
212
|
return null;
|
|
@@ -243,9 +244,74 @@ async function hiddenFrom(c, run) {
|
|
|
243
244
|
}
|
|
244
245
|
async function viewOf(run, hide = new Set(), caller) {
|
|
245
246
|
const w = await db.query.wizard.findFirst({ where: eq(schema.wizard.id, run.wizardId) });
|
|
246
|
-
const view = await runView(run, await brandView(w?.spaceId ?? "", run.definition.themes), hide);
|
|
247
|
+
const view = await runView(run, await brandView(w?.spaceId ?? "", run.definition.themes), hide, caller);
|
|
247
248
|
return caller ? viewFor(view, run, caller) : view;
|
|
248
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* A wizard's connection that is a connection of the space: the run's person signs in to it
|
|
252
|
+
* themselves, as from their menu, with what that connection takes. Only the person whose run it
|
|
253
|
+
* is, signed in to the organization; whether it is open to them the space's own rules say
|
|
254
|
+
* (`allowSignIn`). Null: the connection is the wizard's own.
|
|
255
|
+
*/
|
|
256
|
+
async function spaceSignIn(c, run, connection) {
|
|
257
|
+
if (!connection.spaceConnection) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
const row = await spaceConnectionOf(await spaceIdOf(run), connection.spaceConnection);
|
|
261
|
+
if (!row || row.connectorId !== c.req.param("connectorId")) {
|
|
262
|
+
throw new HTTPException(404, { res: c.json(notFoundAnswer(c), 404) });
|
|
263
|
+
}
|
|
264
|
+
const user = await principalOf(c);
|
|
265
|
+
if (!(user && user.tenantId === run.tenantId && user.id === run.userId)) {
|
|
266
|
+
throw new HTTPException(403, { res: refuse(c, { code: "connectionNotForYou" }, 403) });
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
id: row.id,
|
|
270
|
+
connectorId: row.connectorId,
|
|
271
|
+
as: { as: "person", userId: user.id, role: user.role },
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/** Whether a connect from the run is for the space (decision 2 in docs/plans/run-connections.md). */
|
|
275
|
+
async function wantsForSpace(c) {
|
|
276
|
+
const body = await c.req.json().catch(() => ({}));
|
|
277
|
+
return z
|
|
278
|
+
.object({
|
|
279
|
+
forSpace: z.boolean().optional().default(false),
|
|
280
|
+
values: z.record(z.string(), z.string().max(500)).optional(),
|
|
281
|
+
})
|
|
282
|
+
.parse(body ?? {});
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* An admin of the space connects the account for the space from the run they run themselves: a
|
|
286
|
+
* connection of the space, signed in as the space, and the space's choice for the need. Nobody
|
|
287
|
+
* else, never a guest. Returns the connection to sign in, as the space.
|
|
288
|
+
*/
|
|
289
|
+
async function spaceConnectionFromRun(c, run, connection) {
|
|
290
|
+
const user = await principalOf(c);
|
|
291
|
+
const admin = user &&
|
|
292
|
+
user.tenantId === run.tenantId &&
|
|
293
|
+
user.id === run.userId &&
|
|
294
|
+
isAdminRole(user.role) &&
|
|
295
|
+
!connection.spaceConnection &&
|
|
296
|
+
(await runConnectionsOn());
|
|
297
|
+
if (!admin) {
|
|
298
|
+
throw new HTTPException(403, { res: refuse(c, MEMBERS_EDIT_ONLY, 403) });
|
|
299
|
+
}
|
|
300
|
+
const spaceId = await spaceIdOf(run);
|
|
301
|
+
const home = run.clientSpaceId ?? spaceId;
|
|
302
|
+
const connector = await connectorFor(connection, c.req.param("connectorId") ?? "", spaceId);
|
|
303
|
+
const kept = await spaceConnectorFor(home, connector.id);
|
|
304
|
+
if (!kept) {
|
|
305
|
+
throw new HTTPException(404, { res: c.json(notFoundAnswer(c), 404) });
|
|
306
|
+
}
|
|
307
|
+
const row = await asRole(user.role, () => spaceConnectionForNeed(user.id, home, {
|
|
308
|
+
wizardId: run.wizardId,
|
|
309
|
+
id: connection.id,
|
|
310
|
+
name: connection.title ?? connector.name,
|
|
311
|
+
holder: scopeOf(run).holder,
|
|
312
|
+
}, kept));
|
|
313
|
+
return { id: row.id, role: user.role };
|
|
314
|
+
}
|
|
249
315
|
/**
|
|
250
316
|
* Who may use "Continue now" and "Stop": the owner and the admins of the organization, and on a
|
|
251
317
|
* test run whoever started it. The wait of a live run may be meant, and stays theirs.
|
|
@@ -1422,6 +1488,25 @@ export const runRoutes = new Hono()
|
|
|
1422
1488
|
if (!run || !connection) {
|
|
1423
1489
|
return c.json(notFoundAnswer(c), 404);
|
|
1424
1490
|
}
|
|
1491
|
+
const space = await spaceSignIn(c, run, connection);
|
|
1492
|
+
if (space) {
|
|
1493
|
+
return c.json({
|
|
1494
|
+
url: await startSpaceConnectionOAuth(space.id, space.as, requestLang(c), run.id),
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
if ((await wantsForSpace(c)).forSpace) {
|
|
1498
|
+
try {
|
|
1499
|
+
const made = await spaceConnectionFromRun(c, run, connection);
|
|
1500
|
+
const url = await asRole(made.role, () => startSpaceConnectionOAuth(made.id, { as: "space" }, requestLang(c), run.id));
|
|
1501
|
+
return c.json({ url });
|
|
1502
|
+
}
|
|
1503
|
+
catch (err) {
|
|
1504
|
+
if (err instanceof ServiceError) {
|
|
1505
|
+
return c.json(err.toJSON(requestLang(c)), err.status);
|
|
1506
|
+
}
|
|
1507
|
+
throw err;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1425
1510
|
try {
|
|
1426
1511
|
const url = await startOAuth(scopeOf(run), await spaceIdOf(run), run.id, connection, c.req.param("connectorId"), requestLang(c));
|
|
1427
1512
|
return c.json({ url });
|
|
@@ -1440,12 +1525,32 @@ export const runRoutes = new Hono()
|
|
|
1440
1525
|
if (!run || !connection) {
|
|
1441
1526
|
return c.json(notFoundAnswer(c), 404);
|
|
1442
1527
|
}
|
|
1443
|
-
const { values } =
|
|
1444
|
-
|
|
1445
|
-
|
|
1528
|
+
const { values = {}, forSpace } = await wantsForSpace(c);
|
|
1529
|
+
const space = await spaceSignIn(c, run, connection);
|
|
1530
|
+
if (space) {
|
|
1531
|
+
const { label } = await signInWithCredentials(space.id, space.as, values);
|
|
1532
|
+
await signedIn(run.id);
|
|
1533
|
+
return c.json({ ok: true, label });
|
|
1534
|
+
}
|
|
1535
|
+
if (forSpace) {
|
|
1536
|
+
try {
|
|
1537
|
+
const made = await spaceConnectionFromRun(c, run, connection);
|
|
1538
|
+
const { label } = await asRole(made.role, () => signInWithCredentials(made.id, { as: "space" }, values));
|
|
1539
|
+
signalChanged(run.id);
|
|
1540
|
+
await signedIn(run.id);
|
|
1541
|
+
return c.json({ ok: true, label });
|
|
1542
|
+
}
|
|
1543
|
+
catch (err) {
|
|
1544
|
+
if (err instanceof ServiceError) {
|
|
1545
|
+
return c.json(err.toJSON(requestLang(c)), err.status);
|
|
1546
|
+
}
|
|
1547
|
+
throw err;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1446
1550
|
try {
|
|
1447
1551
|
const label = await connectWithCredentials(scopeOf(run), spaceId, connection, c.req.param("connectorId"), values);
|
|
1448
1552
|
signalChanged(run.id);
|
|
1553
|
+
await signedIn(run.id);
|
|
1449
1554
|
return c.json({ ok: true, label });
|
|
1450
1555
|
}
|
|
1451
1556
|
catch (err) {
|
|
@@ -1454,6 +1559,38 @@ export const runRoutes = new Hono()
|
|
|
1454
1559
|
}
|
|
1455
1560
|
throw err;
|
|
1456
1561
|
}
|
|
1562
|
+
})
|
|
1563
|
+
// The provider's window said the person signed in: a run that waits for it looks again now.
|
|
1564
|
+
.post("/:id/signed-in", async (c) => {
|
|
1565
|
+
const run = await accessibleRun(c, c.req.param("id"));
|
|
1566
|
+
if (!run) {
|
|
1567
|
+
return c.json(notFoundAnswer(c), 404);
|
|
1568
|
+
}
|
|
1569
|
+
signalChanged(run.id);
|
|
1570
|
+
await signedIn(run.id);
|
|
1571
|
+
return c.json({ ok: true });
|
|
1572
|
+
})
|
|
1573
|
+
// The person picks which account the wizard uses for a need: on the card, or to change it.
|
|
1574
|
+
// The choice is theirs alone: someone reading along (an admin too) changes nothing.
|
|
1575
|
+
.put("/:id/connections/:connectionId/choice", async (c) => {
|
|
1576
|
+
const run = await accessibleRun(c, c.req.param("id"));
|
|
1577
|
+
const spaceId = run ? await spaceIdOf(run) : "";
|
|
1578
|
+
const connection = run ? await findConnection(run, c.req.param("connectionId"), spaceId) : null;
|
|
1579
|
+
if (!run || !connection) {
|
|
1580
|
+
return c.json(notFoundAnswer(c), 404);
|
|
1581
|
+
}
|
|
1582
|
+
if (!ownsRun(run, await callerOf(c, run))) {
|
|
1583
|
+
return refuse(c, { code: "connectionNotForYou" }, 403);
|
|
1584
|
+
}
|
|
1585
|
+
const pick = z
|
|
1586
|
+
.object({ owner: z.enum(["person", "space"]), id: z.string().min(1).max(100) })
|
|
1587
|
+
.parse(await c.req.json());
|
|
1588
|
+
if (!(await choose(scopeOf(run), spaceId, connection, pick))) {
|
|
1589
|
+
return c.json(notFoundAnswer(c), 404);
|
|
1590
|
+
}
|
|
1591
|
+
signalChanged(run.id);
|
|
1592
|
+
await signedIn(run.id);
|
|
1593
|
+
return c.json({ ok: true });
|
|
1457
1594
|
})
|
|
1458
1595
|
.delete("/:id/connections/:connectionId", async (c) => {
|
|
1459
1596
|
const run = await accessibleRun(c, c.req.param("id"));
|
|
@@ -1555,13 +1692,14 @@ export const runRoutes = new Hono()
|
|
|
1555
1692
|
title: null,
|
|
1556
1693
|
description: null,
|
|
1557
1694
|
account: { connector: x.provider, label: x.label, connectedAt: x.createdAt },
|
|
1695
|
+
candidates: [],
|
|
1558
1696
|
connectors: [],
|
|
1559
1697
|
}));
|
|
1560
1698
|
return c.json({
|
|
1561
1699
|
lists,
|
|
1562
1700
|
files: await storeFiles(scope),
|
|
1563
1701
|
connections: [
|
|
1564
|
-
...(await connectionViews(run.definition.connections ?? [], scope, await spaceIdOf(run), requestLang(c))).filter((x) => x.account),
|
|
1702
|
+
...(await connectionViews(run.definition.connections ?? [], scope, await spaceIdOf(run), requestLang(c))).filter((x) => x.account || x.candidates.length),
|
|
1565
1703
|
...forSharing,
|
|
1566
1704
|
],
|
|
1567
1705
|
keepsSignIns: secrets.some((s) => s.slot === "browser"),
|
|
@@ -1797,11 +1935,19 @@ export const connectCallback = new Hono().get("/callback", async (c) => {
|
|
|
1797
1935
|
await withTenant(tenant, () => finishPluginOAuth(answer, state));
|
|
1798
1936
|
}
|
|
1799
1937
|
else if (spaceTenant) {
|
|
1800
|
-
await withTenant(tenant, () => finishSpaceConnectionOAuth(answer, state));
|
|
1938
|
+
const done = await withTenant(tenant, () => finishSpaceConnectionOAuth(answer, state));
|
|
1939
|
+
// Signed in from a run's connect card: the run looks again now.
|
|
1940
|
+
if (done.runId) {
|
|
1941
|
+
const runId = done.runId;
|
|
1942
|
+
signalChanged(runId);
|
|
1943
|
+
await withTenant(tenant, () => signedIn(runId)).catch((err) => console.error("[connect] wake", err));
|
|
1944
|
+
}
|
|
1801
1945
|
}
|
|
1802
1946
|
else {
|
|
1803
1947
|
const done = await withTenant(tenant, () => finishOAuth(answer, state));
|
|
1804
1948
|
signalChanged(done.runId);
|
|
1949
|
+
// The account is kept: a wake that fails leaves the run to its next look.
|
|
1950
|
+
await withTenant(tenant, () => signedIn(done.runId)).catch((err) => console.error("[connect] wake", err));
|
|
1805
1951
|
}
|
|
1806
1952
|
ok = true;
|
|
1807
1953
|
said = { code: "connected" };
|
|
@@ -5,7 +5,7 @@ import { LANGS, MODEL_CLASSES, TEXT_CLASSES, } from "@engenty/wizards-shared/def
|
|
|
5
5
|
import { CATEGORY_TYPES, whereSchema } from "@engenty/wizards-shared/knowledge";
|
|
6
6
|
import { PRESENCE_KINDS } from "@engenty/wizards-shared/live";
|
|
7
7
|
import { CLASS_NAMES, isCreditsRef, modelLabel } from "@engenty/wizards-shared/providers";
|
|
8
|
-
import { note } from "@engenty/wizards-shared/run";
|
|
8
|
+
import { note, saidText } from "@engenty/wizards-shared/run";
|
|
9
9
|
import { AUDIENCES } from "@engenty/wizards-shared/rwx";
|
|
10
10
|
import { SPACE_FILE_KINDS } from "@engenty/wizards-shared/spaces";
|
|
11
11
|
import { MAX_MASK_LABEL_CHARS, MAX_MASK_LABELS, modelPolicySchema, } from "@engenty/wizards-shared/tiers";
|
|
@@ -26,11 +26,13 @@ import { assertRwx, folderAudience, setFolderAudience, subjectsOfPerson } from "
|
|
|
26
26
|
import { appStates, connectApps } from "../cli/connect.js";
|
|
27
27
|
import { layout } from "../cli/home.js";
|
|
28
28
|
import { actionKindsPatchSchema, connectorImportSchema, connectorPreviewSchema, importConnector, previewSource, registryService, removeConnector, searchRegistry, setActionKinds, } from "../connectors/external.js";
|
|
29
|
+
import { unwatchedScope } from "../connectors/person-connections.js";
|
|
29
30
|
import { reloadConnector } from "../connectors/reload.js";
|
|
31
|
+
import { chooseForSpace, clearForSpace, wizardNeeds } from "../connectors/space-choice.js";
|
|
30
32
|
import { balanceCredits, canSpend } from "../credits/credits.js";
|
|
31
33
|
import { estimateRun } from "../credits/estimate.js";
|
|
32
34
|
import { listNotices, markNoticesRead } from "../engine/notices.js";
|
|
33
|
-
import { missingModels, stepsWithoutModel } from "../engine/requirements.js";
|
|
35
|
+
import { missingConnections, missingModels, stepsWithoutModel, unwatchedConnectionsSaid, } from "../engine/requirements.js";
|
|
34
36
|
import { env } from "../env.js";
|
|
35
37
|
import { feature, features, forgetAccountFeatures } from "../features.js";
|
|
36
38
|
import { appleStatus } from "../harness/apple.js";
|
|
@@ -655,9 +657,10 @@ export const studio = new Hono()
|
|
|
655
657
|
.object({
|
|
656
658
|
name: z.string().min(1).max(80),
|
|
657
659
|
access: z.enum(["all", "members"]).default("all"),
|
|
660
|
+
kind: z.enum(["space", "client"]).default("space"),
|
|
658
661
|
})
|
|
659
662
|
.parse(await c.req.json());
|
|
660
|
-
return c.json(await createSpace(c.get("user").id, body.name, body.access));
|
|
663
|
+
return c.json(await createSpace(c.get("user").id, body.name, body.access, body.kind));
|
|
661
664
|
})
|
|
662
665
|
.patch("/spaces/:id", async (c) => {
|
|
663
666
|
const patch = spacePatchSchema.parse(await c.req.json());
|
|
@@ -1395,10 +1398,44 @@ export const studio = new Hono()
|
|
|
1395
1398
|
const w = await ownedWizard(c.get("user").id, c.req.param("id"));
|
|
1396
1399
|
return c.json(await wizardRunners(w));
|
|
1397
1400
|
})
|
|
1398
|
-
// The models the draft needs that this runtime cannot serve, by class, with the steps that call
|
|
1401
|
+
// The models the draft needs that this runtime cannot serve, by class, with the steps that call
|
|
1402
|
+
// them; and its connections whose connectors can't connect here. An admin reads what the
|
|
1403
|
+
// server's owner has to set.
|
|
1399
1404
|
.get("/wizards/:id/models", async (c) => {
|
|
1405
|
+
const user = c.get("user");
|
|
1406
|
+
const w = await ownedWizard(user.id, c.req.param("id"));
|
|
1407
|
+
const lang = requestLang(c);
|
|
1408
|
+
// A start nobody owns runs with nobody there: it needs the space's choice for each need.
|
|
1409
|
+
const unwatched = w.starts.some((s) => s.on && !s.owner)
|
|
1410
|
+
? await unwatchedConnectionsSaid(w.draft, unwatchedScope(w.id), w.spaceId)
|
|
1411
|
+
: [];
|
|
1412
|
+
return c.json({
|
|
1413
|
+
missing: await missingModels(w.draft, lang),
|
|
1414
|
+
connections: [
|
|
1415
|
+
...(await missingConnections(w.draft, w.spaceId, lang, isAdminRole(user.role))),
|
|
1416
|
+
...unwatched.map((m) => ({ ...m, problem: saidText(m.problem, lang) })),
|
|
1417
|
+
],
|
|
1418
|
+
});
|
|
1419
|
+
})
|
|
1420
|
+
// The wizard's needs (docs/plans/run-connections.md, step 4): how each resolves for the person
|
|
1421
|
+
// looking; for the space's admins also the space's choice for runs nobody watches.
|
|
1422
|
+
.get("/wizards/:id/needs", async (c) => {
|
|
1423
|
+
const user = c.get("user");
|
|
1424
|
+
const w = await ownedWizard(user.id, c.req.param("id"));
|
|
1425
|
+
return c.json({
|
|
1426
|
+
needs: await wizardNeeds(w, { userId: user.id, admin: isAdminRole(user.role) }, requestLang(c)),
|
|
1427
|
+
});
|
|
1428
|
+
})
|
|
1429
|
+
.put("/wizards/:id/needs/:need/space-choice", async (c) => {
|
|
1400
1430
|
const w = await ownedWizard(c.get("user").id, c.req.param("id"));
|
|
1401
|
-
|
|
1431
|
+
const { connection } = z.object({ connection: z.string().min(1) }).parse(await c.req.json());
|
|
1432
|
+
await chooseForSpace(w, c.req.param("need"), connection);
|
|
1433
|
+
return c.json({ ok: true });
|
|
1434
|
+
})
|
|
1435
|
+
.delete("/wizards/:id/needs/:need/space-choice", async (c) => {
|
|
1436
|
+
const w = await ownedWizard(c.get("user").id, c.req.param("id"));
|
|
1437
|
+
await clearForSpace(w, c.req.param("need"));
|
|
1438
|
+
return c.json({ ok: true });
|
|
1402
1439
|
})
|
|
1403
1440
|
// A runtime that runs alone: the wizard's copy in the cloud of the linked account.
|
|
1404
1441
|
.get("/wizards/:id/cloud", async (c) => {
|