@engenty/wizards-runtime 0.19.1 → 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 +209 -16
- 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/authoring.md +13 -3
- 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/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-BUWu36Mb.js → AboutDialog-QWzpEK8M.js} +1 -1
- package/apps/web/dist/assets/{BlockEditor-1-EvUIta.js → BlockEditor-C44bI_ih.js} +1 -1
- package/apps/web/dist/assets/{Bundle-RNkjBwAL.js → Bundle-DZyQ1FP7.js} +1 -1
- package/apps/web/dist/assets/CapabilitiesPage-DAr0-gN1.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-C_ZZLRZT.js → ChangelogDialog-CdHqJV2P.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-BEJKIMd0.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-ptI86Ogs.js → FlowPreview-aj58c-gH.js} +1 -1
- package/apps/web/dist/assets/{LangSwitch-BNa_H8AR.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-YF0RkR7P.js → ReadOnly-C6qmTD35.js} +1 -1
- package/apps/web/dist/assets/{Results-DJRLiVo0.js → Results-BNuuBiwU.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-CSpTNJp-.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-OiKEnmL1.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-BpdsLIOc.js → UpdateCheck-D3QhfI5c.js} +2 -2
- package/apps/web/dist/assets/{brand-ByQY-UcL.js → brand-DKuVyYhH.js} +1 -1
- package/apps/web/dist/assets/changelog-Db3nvWao.js +1 -0
- package/apps/web/dist/assets/{code-editor-B8zG80PA.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-D18zQ05f.css → index-CduFlFCp.css} +1 -1
- package/apps/web/dist/assets/index-CtE0rJEL.js +102 -0
- package/apps/web/dist/assets/{read-aloud-spC7eEBp.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-CoEdB_9_.js → useMutation-fT44ij_b.js} +1 -1
- package/apps/web/dist/assets/{viewers-BmcrgvXX.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 +54 -1
- package/node_modules/@engenty/wizards-shared/dist/run.js +23 -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 +5 -1
- 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-fgTP28Mn.js +0 -2
- package/apps/web/dist/assets/ConnectorsSection-iLrduYak.js +0 -1
- package/apps/web/dist/assets/EditorPage-CRZte0O1.js +0 -3
- package/apps/web/dist/assets/Marketplace-9aGWG2pJ.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-BFDm9vCT.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-ueGFlLDo.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-DtDd7k_O.js +0 -1
- package/apps/web/dist/assets/PreviewPane-CEltrf_-.js +0 -7
- package/apps/web/dist/assets/ProtocolSection-Bb3c44Te.js +0 -1
- package/apps/web/dist/assets/PublicRunner-BaTg24s3.js +0 -1
- package/apps/web/dist/assets/SettingsPage--_ap3omw.js +0 -2
- package/apps/web/dist/assets/SetupPage-ELKHbmnE.js +0 -1
- package/apps/web/dist/assets/SkillEditor-C1_zwNOQ.js +0 -1
- package/apps/web/dist/assets/Skills-_pLGtOjH.js +0 -9
- package/apps/web/dist/assets/SpacePage-r4EbxEJe.js +0 -2
- package/apps/web/dist/assets/StudioHome-CwvxI29m.js +0 -1
- package/apps/web/dist/assets/changelog-Dt-V-BKp.js +0 -1
- package/apps/web/dist/assets/host-Ckjz94Ea.js +0 -69
- package/apps/web/dist/assets/i18n-ClCOlfx2.js +0 -55
- package/apps/web/dist/assets/index-BHKh0A9F.js +0 -10
- package/apps/web/dist/assets/runners-DNqzwMQ0.js +0 -1
- package/apps/web/dist/assets/session-Dd9duhPc.js +0 -1
- package/apps/web/dist/assets/theme-DumM6FI_.js +0 -14
- package/apps/web/dist/assets/ui-BjhZhw8x.js +0 -16
|
@@ -13,10 +13,12 @@ import { and, eq, lt, notInArray, sql } from "drizzle-orm";
|
|
|
13
13
|
import { nanoid } from "nanoid";
|
|
14
14
|
import { currentImpersonator } from "../auth/impersonation.js";
|
|
15
15
|
import { effectsOn, enterVisit } from "../broker/effect.js";
|
|
16
|
-
import { grantNote, grantOf, kindOf } from "../broker/index.js";
|
|
16
|
+
import { grantNote, grantOf, inAudience, kindOf } from "../broker/index.js";
|
|
17
17
|
import { runHolder, subjectsOf } from "../broker/rwx.js";
|
|
18
18
|
import { resolveConnector } from "../connectors/external.js";
|
|
19
|
-
import { connectionViews } from "../connectors/index.js";
|
|
19
|
+
import { candidates, connectionViews, connectorOptions } from "../connectors/index.js";
|
|
20
|
+
import { runConnectionsOn } from "../connectors/person-connections.js";
|
|
21
|
+
import { spaceConnectionOf, spaceConnectorFor } from "../connectors/space-connections.js";
|
|
20
22
|
import { addLocalCost, canSpend, releaseRun, reserveForRun, syncRunCost, } from "../credits/credits.js";
|
|
21
23
|
import { estimateRun } from "../credits/estimate.js";
|
|
22
24
|
import { db, schema, withTenant } from "../db/client.js";
|
|
@@ -33,7 +35,7 @@ import { prompt } from "../prompts.js";
|
|
|
33
35
|
import { ContentBlockedError, checkGuestInput, checkGuestText, guestChecksOn, guestRun, } from "../safety.js";
|
|
34
36
|
import { sandboxDataHost } from "../sandbox/data.js";
|
|
35
37
|
import { peerTicket } from "../secrets/signing.js";
|
|
36
|
-
import { nameOf } from "../services/access.js";
|
|
38
|
+
import { isAdminRole, nameOf } from "../services/access.js";
|
|
37
39
|
import { snapshotFile } from "../services/files.js";
|
|
38
40
|
import { reportRun } from "../services/manage-reports.js";
|
|
39
41
|
import { switchedOffRunners } from "../services/runners.js";
|
|
@@ -59,8 +61,9 @@ import { readFormInput } from "./input.js";
|
|
|
59
61
|
import { withMailText } from "./mail-watch.js";
|
|
60
62
|
import { noticeFor, noticesFor, noticeWrites, } from "./notices.js";
|
|
61
63
|
import { pushRun } from "./push.js";
|
|
62
|
-
import { blockingMessage, closedChoices, maskedNote, missingModelsSaid, openValue, stepsWithoutModel, tierRefusalSaid, } from "./requirements.js";
|
|
64
|
+
import { blockingMessage, closedChoices, maskedNote, missingConnectionsSaid, missingModelsSaid, openValue, stepsWithoutModel, tierRefusalSaid, } from "./requirements.js";
|
|
63
65
|
import { liveResources, releaseResources, resourcesFor } from "./resources.js";
|
|
66
|
+
import { needsAhead, needsOfStep, unconnected } from "./run-needs.js";
|
|
64
67
|
import { dropWait, findSignal, registerWait, runScope, SPACE_SCOPE, sendSignal, } from "./signals.js";
|
|
65
68
|
import { startedRunEnded, startOf } from "./starts.js";
|
|
66
69
|
import { outputSchema, runAutomaticStep } from "./steps.js";
|
|
@@ -148,7 +151,7 @@ export async function loadSpace(run) {
|
|
|
148
151
|
}
|
|
149
152
|
return p;
|
|
150
153
|
}
|
|
151
|
-
/** Where a run's data is: the
|
|
154
|
+
/** Where a run's data is: the space it carries, else its wizard's space. */
|
|
152
155
|
async function dataSpaceOf(run, space) {
|
|
153
156
|
if (!run.clientSpaceId) {
|
|
154
157
|
return { id: space.id, name: space.name };
|
|
@@ -158,7 +161,7 @@ async function dataSpaceOf(run, space) {
|
|
|
158
161
|
where: eq(schema.space.id, run.clientSpaceId),
|
|
159
162
|
});
|
|
160
163
|
if (!client) {
|
|
161
|
-
throw new Error("
|
|
164
|
+
throw new Error("space missing");
|
|
162
165
|
}
|
|
163
166
|
return client;
|
|
164
167
|
}
|
|
@@ -428,8 +431,12 @@ export async function createRun(input) {
|
|
|
428
431
|
if (noData) {
|
|
429
432
|
throw new ModelUnavailableError(noData);
|
|
430
433
|
}
|
|
431
|
-
// A step every run passes through needs a model this runtime cannot serve
|
|
432
|
-
|
|
434
|
+
// A step every run passes through needs a model this runtime cannot serve, or a connection none
|
|
435
|
+
// of whose connectors connects here: refuse before anything is held.
|
|
436
|
+
const blocked = blockingMessage([
|
|
437
|
+
...(await missingModelsSaid(input.definition)),
|
|
438
|
+
...(await missingConnectionsSaid(input.definition, await spaceIdOf(input))),
|
|
439
|
+
]);
|
|
433
440
|
if (blocked) {
|
|
434
441
|
throw new ModelUnavailableError(blocked);
|
|
435
442
|
}
|
|
@@ -444,8 +451,8 @@ export async function createRun(input) {
|
|
|
444
451
|
}
|
|
445
452
|
// What the run may reach outside, from the definition it starts on: fixed here, never widened.
|
|
446
453
|
const grant = grantOf(input.definition);
|
|
447
|
-
// Without an account nobody can come back for a result later: it is kept a week. A run
|
|
448
|
-
//
|
|
454
|
+
// Without an account nobody can come back for a result later: it is kept a week. A run that
|
|
455
|
+
// carries its space is kept with that space.
|
|
449
456
|
const expiresAt = input.mode === "live" && !input.clientSpaceId
|
|
450
457
|
? new Date(Date.now() + env.limits.resultTtlDays * 24 * 60 * 60 * 1000)
|
|
451
458
|
: null;
|
|
@@ -1584,9 +1591,7 @@ async function failSaid(err) {
|
|
|
1584
1591
|
* isn't looking. A crash before the run sleeps tells again, and that notice replaces this one.
|
|
1585
1592
|
*/
|
|
1586
1593
|
async function tellPerson(run, stepId, pause) {
|
|
1587
|
-
const said = pause.kind === "sign_in"
|
|
1588
|
-
? note("stepWaitsSignIn", { service: pause.service })
|
|
1589
|
-
: note("stepWaitsCredits");
|
|
1594
|
+
const said = pause.kind === "sign_in" ? await signInSaid(run, pause) : note("stepWaitsCredits");
|
|
1590
1595
|
await emitEvent(run.id, stepId, "error", said);
|
|
1591
1596
|
try {
|
|
1592
1597
|
const notice = await noticeFor(run, "needs_you", {
|
|
@@ -1613,9 +1618,85 @@ async function waitForPerson(run, at, failure, seen) {
|
|
|
1613
1618
|
seen,
|
|
1614
1619
|
err: failure.class === "credits"
|
|
1615
1620
|
? new NoCreditsError()
|
|
1616
|
-
: new NotedError(
|
|
1621
|
+
: new NotedError(await signInSaid(run, failure)),
|
|
1617
1622
|
});
|
|
1618
1623
|
}
|
|
1624
|
+
/**
|
|
1625
|
+
* A step uses a need the run has no account for (none, or several and none chosen): the run waits
|
|
1626
|
+
* for the person to connect or choose one, as long as it takes. Their card says so; it goes on at
|
|
1627
|
+
* once after (`signedIn`).
|
|
1628
|
+
*/
|
|
1629
|
+
async function waitForAccount(run, step, need) {
|
|
1630
|
+
const spaceId = await spaceIdOf(run);
|
|
1631
|
+
const service = need.title ?? (await candidates(need, spaceId))[0]?.name ?? need.id;
|
|
1632
|
+
const pause = { kind: "sign_in", service, connection: need.id };
|
|
1633
|
+
const state = structuredClone(run.state);
|
|
1634
|
+
// Woken before anything was connected, it waits again and says nothing new.
|
|
1635
|
+
const told = state.retries?.step === step.id && state.retries.told === "sign_in";
|
|
1636
|
+
state.pause = pause;
|
|
1637
|
+
state.retries = {
|
|
1638
|
+
...(state.retries?.step === step.id
|
|
1639
|
+
? state.retries
|
|
1640
|
+
: { step: step.id, count: 0, since: new Date().toISOString() }),
|
|
1641
|
+
told: "sign_in",
|
|
1642
|
+
};
|
|
1643
|
+
await updateRun(run.id, { status: "sleeping", state, wakeAt: null }, { status: "running" });
|
|
1644
|
+
if (!told) {
|
|
1645
|
+
await tellPerson(run, step.id, pause);
|
|
1646
|
+
void pushRun(run.id, "waiting");
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* The wizard's need a sign-in is for, where the run has no account to use for it: the connect
|
|
1651
|
+
* card's (`RunView.connect`), not a new sign-in's. With `runConnections` off, never.
|
|
1652
|
+
*/
|
|
1653
|
+
async function unconnectedNeed(run, connectionId) {
|
|
1654
|
+
const need = run.definition.connections?.find((c) => c.id === connectionId);
|
|
1655
|
+
if (!(need && (await runConnectionsOn()))) {
|
|
1656
|
+
return null;
|
|
1657
|
+
}
|
|
1658
|
+
return (await unconnected(scopeOf(run), await spaceIdOf(run), [need])).length ? need : null;
|
|
1659
|
+
}
|
|
1660
|
+
/** The connection of the space behind the wizard's connection a sign-in is for, if it is one. */
|
|
1661
|
+
async function spaceRowOf(run, connectionId) {
|
|
1662
|
+
const named = run.definition.connections?.find((c) => c.id === connectionId)?.spaceConnection;
|
|
1663
|
+
return named ? spaceConnectionOf(await spaceIdOf(run), named) : null;
|
|
1664
|
+
}
|
|
1665
|
+
/** What a run that waits for a sign-in says: one that signs in as the space is an admin's to fix. */
|
|
1666
|
+
async function signInSaid(run, pause) {
|
|
1667
|
+
if (await unconnectedNeed(run, pause.connection)) {
|
|
1668
|
+
return note("stepWaitsConnect", { service: pause.service });
|
|
1669
|
+
}
|
|
1670
|
+
const row = await spaceRowOf(run, pause.connection);
|
|
1671
|
+
return note(row?.signIn === "space" ? "stepWaitsAdminSignIn" : "stepWaitsSignIn", {
|
|
1672
|
+
service: pause.service,
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* The person signed in: a run that waits for a sign-in to one of the wizard's connections looks
|
|
1677
|
+
* again now, not at its next look. Still not signed in, the step waits again and says nothing new.
|
|
1678
|
+
*/
|
|
1679
|
+
export async function signedIn(runId) {
|
|
1680
|
+
const run = await loadRun(runId);
|
|
1681
|
+
const pause = run?.status === "sleeping" ? run.state.pause : undefined;
|
|
1682
|
+
if (!(run && pause?.kind === "sign_in" && pause.connection)) {
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
const now = new Date();
|
|
1686
|
+
try {
|
|
1687
|
+
await updateRun(run.id, { wakeAt: now }, { rev: run.rev });
|
|
1688
|
+
}
|
|
1689
|
+
catch (err) {
|
|
1690
|
+
// It moved on meanwhile: it no longer waits for this.
|
|
1691
|
+
if (err instanceof RunConflict) {
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
throw err;
|
|
1695
|
+
}
|
|
1696
|
+
await setWake(run.id, now);
|
|
1697
|
+
await wakeDue(now);
|
|
1698
|
+
kick(run.id);
|
|
1699
|
+
}
|
|
1619
1700
|
/**
|
|
1620
1701
|
* The error as the flow sorts it. A retry starts the step from the top, so one that may have done
|
|
1621
1702
|
* something out there is not started again by itself, or the mail goes out twice: a person can still
|
|
@@ -1629,7 +1710,11 @@ function flowFailure(err, failure, acted) {
|
|
|
1629
1710
|
return { class: "credits" };
|
|
1630
1711
|
case "sign_in":
|
|
1631
1712
|
if (err instanceof SignInNeeded) {
|
|
1632
|
-
return {
|
|
1713
|
+
return {
|
|
1714
|
+
class: "sign_in",
|
|
1715
|
+
service: err.service,
|
|
1716
|
+
...(err.connection ? { connection: err.connection } : {}),
|
|
1717
|
+
};
|
|
1633
1718
|
}
|
|
1634
1719
|
return acted ? { class: "final" } : { class: "sign_in", service: "" };
|
|
1635
1720
|
default:
|
|
@@ -1849,6 +1934,14 @@ async function drive(runId, signal) {
|
|
|
1849
1934
|
void pushRun(runId, "waiting");
|
|
1850
1935
|
return;
|
|
1851
1936
|
}
|
|
1937
|
+
// A need of this step with no account to use: the person connects or chooses one first.
|
|
1938
|
+
if (await runConnectionsOn()) {
|
|
1939
|
+
const [missing] = await unconnected(scopeOf(run), await spaceIdOf(run), needsOfStep(def, step));
|
|
1940
|
+
if (missing) {
|
|
1941
|
+
await waitForAccount(run, step, missing);
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1852
1945
|
// An answer moved the run on without holding again (`answerGoesOn`): it holds before it spends.
|
|
1853
1946
|
if (run.state.holdLater) {
|
|
1854
1947
|
const refused = await holdAgain(run).catch((err) => {
|
|
@@ -2470,11 +2563,109 @@ export async function talkAllowed(run) {
|
|
|
2470
2563
|
const { enabled } = w?.runners ?? DEFAULT_RUNNER_SETTINGS;
|
|
2471
2564
|
return enabled.some((id) => CONVERSATION_RUNNERS.includes(id) && !off.has(id));
|
|
2472
2565
|
}
|
|
2566
|
+
/** The viewer is the person whose run it is. */
|
|
2567
|
+
export const ownsRun = (run, viewer) => Boolean(viewer.local ||
|
|
2568
|
+
viewer.link ||
|
|
2569
|
+
(viewer.userId && viewer.userId === run.userId) ||
|
|
2570
|
+
(viewer.visitorId && viewer.visitorId === run.visitorId));
|
|
2571
|
+
/**
|
|
2572
|
+
* What a run that waits for a sign-in to one of the wizard's connections offers the viewer. A
|
|
2573
|
+
* connection that signs in as the space is an admin's to sign in again. The card is for the
|
|
2574
|
+
* person whose run it is: the wizard's own account, or their own sign-in to a connection of the
|
|
2575
|
+
* space where each person signs in, if it is open to them. A guest never gets that one.
|
|
2576
|
+
*/
|
|
2577
|
+
async function signInOf(run, def, viewer) {
|
|
2578
|
+
const pause = run.status === "sleeping" ? run.state.pause : undefined;
|
|
2579
|
+
const connection = pause?.kind === "sign_in" ? def.connections?.find((c) => c.id === pause.connection) : undefined;
|
|
2580
|
+
if (!connection) {
|
|
2581
|
+
return null;
|
|
2582
|
+
}
|
|
2583
|
+
const row = await spaceRowOf(run, connection.id);
|
|
2584
|
+
if (connection.spaceConnection && !row) {
|
|
2585
|
+
return null;
|
|
2586
|
+
}
|
|
2587
|
+
if (row?.signIn === "space") {
|
|
2588
|
+
return { admin: true };
|
|
2589
|
+
}
|
|
2590
|
+
if (!(viewer && ownsRun(run, viewer))) {
|
|
2591
|
+
return null;
|
|
2592
|
+
}
|
|
2593
|
+
const spaceId = await spaceIdOf(run);
|
|
2594
|
+
const lang = textLang(wizardLang(def));
|
|
2595
|
+
// No account to use for it at all: the connect card of `RunView.connect` asks.
|
|
2596
|
+
if (!row && (await unconnectedNeed(run, connection.id))) {
|
|
2597
|
+
return null;
|
|
2598
|
+
}
|
|
2599
|
+
if (!row) {
|
|
2600
|
+
const [view] = await connectionViews([connection], scopeOf(run), spaceId, lang);
|
|
2601
|
+
// An account the step met and could not use is no account: the card connects anew.
|
|
2602
|
+
return { connection: { ...view, account: null } };
|
|
2603
|
+
}
|
|
2604
|
+
const who = {
|
|
2605
|
+
kind: viewer.role && isAdminRole(viewer.role) ? "admin" : "person",
|
|
2606
|
+
id: viewer.userId ?? "",
|
|
2607
|
+
};
|
|
2608
|
+
if (!(run.userId && viewer.userId === run.userId && inAudience(row.audience, who))) {
|
|
2609
|
+
return null;
|
|
2610
|
+
}
|
|
2611
|
+
return {
|
|
2612
|
+
connection: {
|
|
2613
|
+
id: connection.id,
|
|
2614
|
+
kind: connection.kind ?? null,
|
|
2615
|
+
connector: row.connectorId,
|
|
2616
|
+
title: connection.title ?? row.name,
|
|
2617
|
+
description: connection.description ?? null,
|
|
2618
|
+
account: null,
|
|
2619
|
+
candidates: [],
|
|
2620
|
+
connectors: await connectorOptions({ id: connection.id, connector: row.connectorId }, spaceId, lang),
|
|
2621
|
+
},
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
/**
|
|
2625
|
+
* What the run asks the viewer to connect or choose before it goes on (`RunView.connect`), for
|
|
2626
|
+
* the person whose run it is: at its start (nothing passed yet) the needs of the steps every run
|
|
2627
|
+
* passes, and the need of the step it waits at. A need used on a branch only asks when the run
|
|
2628
|
+
* gets there. With `runConnections` off, nothing: a page field connects, as before.
|
|
2629
|
+
*/
|
|
2630
|
+
async function connectOf(run, def, viewer) {
|
|
2631
|
+
if (!(viewer && ownsRun(run, viewer) && def.connections?.length)) {
|
|
2632
|
+
return [];
|
|
2633
|
+
}
|
|
2634
|
+
if (!(await runConnectionsOn())) {
|
|
2635
|
+
return [];
|
|
2636
|
+
}
|
|
2637
|
+
const pause = run.status === "sleeping" ? run.state.pause : undefined;
|
|
2638
|
+
const waits = pause?.kind === "sign_in" ? def.connections.filter((c) => c.id === pause.connection) : [];
|
|
2639
|
+
const starting = !run.state.history.length && (run.status === "waiting_input" || waits.length > 0);
|
|
2640
|
+
const ahead = starting ? needsAhead(def, def.steps[0].id, run.state.values) : [];
|
|
2641
|
+
const needs = [...new Set([...waits, ...ahead])];
|
|
2642
|
+
const spaceId = await spaceIdOf(run);
|
|
2643
|
+
const scope = scopeOf(run);
|
|
2644
|
+
const missing = await unconnected(scope, spaceId, needs);
|
|
2645
|
+
if (!missing.length) {
|
|
2646
|
+
return [];
|
|
2647
|
+
}
|
|
2648
|
+
// An admin of the space whose run it is may connect for the space; a guest never.
|
|
2649
|
+
const admin = Boolean(viewer.userId && viewer.userId === run.userId && viewer.role && isAdminRole(viewer.role));
|
|
2650
|
+
const home = run.clientSpaceId ?? spaceId;
|
|
2651
|
+
const views = await connectionViews(missing, scope, spaceId, textLang(wizardLang(def)));
|
|
2652
|
+
return Promise.all(views.map(async (view) => {
|
|
2653
|
+
const forSpace = [];
|
|
2654
|
+
for (const c of admin ? view.connectors : []) {
|
|
2655
|
+
if (await spaceConnectorFor(home, c.id)) {
|
|
2656
|
+
forSpace.push(c.id);
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
return { ...view, forSpace };
|
|
2660
|
+
}));
|
|
2661
|
+
}
|
|
2473
2662
|
/**
|
|
2474
2663
|
* The run as the viewer sees it. `hide`: steps whose output stays in the space (broker/kept.ts):
|
|
2475
2664
|
* shown with no output and `kept`, left out of `outputs`; empty for a member, or a member's run.
|
|
2665
|
+
* `viewer`: who looks, for what only they can do here (the connect card while the run waits for
|
|
2666
|
+
* their sign-in).
|
|
2476
2667
|
*/
|
|
2477
|
-
export async function runView(run, brand, hide = new Set()) {
|
|
2668
|
+
export async function runView(run, brand, hide = new Set(), viewer) {
|
|
2478
2669
|
// In the viewer's language every text of the view is the translation; ids and values stay.
|
|
2479
2670
|
const memory = run.lang ? await storedTranslation(run.wizardId, run.lang) : null;
|
|
2480
2671
|
const translated = memory ? translateDefinition(run.definition, memory) : null;
|
|
@@ -2536,6 +2727,8 @@ export async function runView(run, brand, hide = new Set()) {
|
|
|
2536
2727
|
? (run.wakeAt?.toISOString() ?? null)
|
|
2537
2728
|
: null,
|
|
2538
2729
|
pause: run.status === "sleeping" ? (run.state.pause ?? null) : null,
|
|
2730
|
+
signIn: await signInOf(run, def, viewer),
|
|
2731
|
+
connect: await connectOf(run, def, viewer),
|
|
2539
2732
|
waitsFor: run.status === "waiting_signal" && step?.type === "wait"
|
|
2540
2733
|
? waitKeyText(run, step) || null
|
|
2541
2734
|
: null,
|
|
@@ -2,6 +2,7 @@ import { textLang, wizardLang } from "@engenty/wizards-shared/definition";
|
|
|
2
2
|
import { saidText } from "@engenty/wizards-shared/run";
|
|
3
3
|
import { dueOccurrence, fillOf, occurrenceKey, START_FAILURES_TO_PAUSE, } from "@engenty/wizards-shared/starts";
|
|
4
4
|
import { and, eq, isNull, ne, notInArray, or, sql } from "drizzle-orm";
|
|
5
|
+
import { unwatchedScope } from "../connectors/person-connections.js";
|
|
5
6
|
import { control, controlDb, db, schema, withTenant } from "../db/client.js";
|
|
6
7
|
import { env } from "../env.js";
|
|
7
8
|
import { currentFeatures } from "../features.js";
|
|
@@ -9,6 +10,7 @@ import { wizardUnavailable } from "../limits.js";
|
|
|
9
10
|
import { noteOf } from "../model-errors.js";
|
|
10
11
|
import { publishedVersion } from "../services/wizards.js";
|
|
11
12
|
import { addNotice } from "./notices.js";
|
|
13
|
+
import { blockingMessage, unwatchedConnectionsSaid } from "./requirements.js";
|
|
12
14
|
import { createRun, OccurrenceTaken } from "./runner.js";
|
|
13
15
|
/**
|
|
14
16
|
* Starts: what begins a run without a person. Schedules are looked at once a minute by every
|
|
@@ -79,6 +81,13 @@ export async function startFrom(w, start, event, options = {}) {
|
|
|
79
81
|
if (!version) {
|
|
80
82
|
throw new StartRefused(saidText({ code: "wizardUnavailable" }, textLang(wizardLang(w.draft))));
|
|
81
83
|
}
|
|
84
|
+
// A start nobody owns runs with nobody there: it uses the space's choice for each need.
|
|
85
|
+
const unwatched = start.owner
|
|
86
|
+
? null
|
|
87
|
+
: blockingMessage(await unwatchedConnectionsSaid(version.definition, unwatchedScope(w.id), w.spaceId));
|
|
88
|
+
if (unwatched) {
|
|
89
|
+
throw new StartRefused(saidText(unwatched, textLang(wizardLang(w.draft))));
|
|
90
|
+
}
|
|
82
91
|
const runId = await createRun({
|
|
83
92
|
wizardId: w.id,
|
|
84
93
|
definition: version.definition,
|
|
@@ -5,8 +5,12 @@ export class StepError extends NotedError {
|
|
|
5
5
|
/** A fixed step's connection isn't signed in, or the service turned the sign-in down. */
|
|
6
6
|
export class SignInNeeded extends StepError {
|
|
7
7
|
service;
|
|
8
|
-
|
|
8
|
+
connection;
|
|
9
|
+
constructor(service, said,
|
|
10
|
+
/** The wizard's connection, by its id in `connections`, the sign-in is for. */
|
|
11
|
+
connection) {
|
|
9
12
|
super(said);
|
|
10
13
|
this.service = service;
|
|
14
|
+
this.connection = connection;
|
|
11
15
|
}
|
|
12
16
|
}
|
|
@@ -91,7 +91,9 @@ class ClaudeCodeModel extends HarnessModel {
|
|
|
91
91
|
args.push("--effort", call.effort);
|
|
92
92
|
}
|
|
93
93
|
if (call.schema) {
|
|
94
|
-
|
|
94
|
+
// The CLI checks the schema with no dialects loaded: one that names its own is refused.
|
|
95
|
+
const { $schema: _dialect, ...schema } = call.schema;
|
|
96
|
+
args.push("--json-schema", JSON.stringify(schema));
|
|
95
97
|
}
|
|
96
98
|
if (call.bridgeUrl) {
|
|
97
99
|
args.push("--mcp-config", JSON.stringify({ mcpServers: { step: { type: "http", url: call.bridgeUrl } } }));
|
|
@@ -37,7 +37,7 @@ function toClaims(payload) {
|
|
|
37
37
|
if (typeof p.sub !== "string" || typeof p.tenant !== "string") {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
// A role this runtime does not know gets the least: a client's (docs/plans/
|
|
40
|
+
// A role this runtime does not know gets the least: a client's (docs/plans/org-spaces.md).
|
|
41
41
|
const role = p.role === "owner" || p.role === "admin" || p.role === "member" || p.role === "client"
|
|
42
42
|
? p.role
|
|
43
43
|
: "client";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { signalNameSchema } from "@engenty/wizards-shared/definition";
|
|
2
2
|
import { describeStart, startInputSchema } from "@engenty/wizards-shared/starts";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { authoringGuide } from "../authoring/guide.js";
|
|
4
|
+
import { authoringGuide, guideMail } from "../authoring/guide.js";
|
|
5
5
|
import { wizardOpSchema } from "../authoring/ops.js";
|
|
6
6
|
import { importFromRegistry, listConnectors, searchRegistry } from "../connectors/external.js";
|
|
7
7
|
import { guideSpaceConnections } from "../connectors/space-connections.js";
|
|
@@ -101,7 +101,7 @@ function presentNote(people) {
|
|
|
101
101
|
}
|
|
102
102
|
export function registerTools(server, who) {
|
|
103
103
|
// A client of the organization authors nothing: only the elements of their client spaces
|
|
104
|
-
// (mcp/elements.ts, docs/plans/
|
|
104
|
+
// (mcp/elements.ts, docs/plans/org-spaces.md).
|
|
105
105
|
if (who.role === "client") {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
@@ -216,7 +216,7 @@ export function registerTools(server, who) {
|
|
|
216
216
|
readOnly: true,
|
|
217
217
|
}, async ({ spaceId }) => {
|
|
218
218
|
const space = await studioSpace(spaceId);
|
|
219
|
-
return authoringGuide(await listConnectors(space.id), await pluginToolsOf(who.tenantId), await guideSpaceConnections(space.id), await currentFeatures());
|
|
219
|
+
return authoringGuide(await listConnectors(space.id), await guideMail(), await pluginToolsOf(who.tenantId), await guideSpaceConnections(space.id), await currentFeatures());
|
|
220
220
|
});
|
|
221
221
|
// --- connectors ------------------------------------------------------------
|
|
222
222
|
tool("find_connectors", "wizards:read", {
|
|
@@ -19,6 +19,7 @@ import { notFound, ServiceError } from "../services/errors.js";
|
|
|
19
19
|
import { runnerSettingsOf, runnersOf } from "../services/runners.js";
|
|
20
20
|
import { pluginAnswerableRun, pluginRun, refusedInput, runReportOf, waitRun, } from "../services/runs.js";
|
|
21
21
|
import { shareUrl } from "../services/wizards.js";
|
|
22
|
+
import { CHANNEL_VISITOR } from "../store/index.js";
|
|
22
23
|
import { visitorOverLimit } from "../tenants/control.js";
|
|
23
24
|
import { currentTenant } from "../tenants/tenant.js";
|
|
24
25
|
/**
|
|
@@ -29,7 +30,7 @@ import { currentTenant } from "../tenants/tenant.js";
|
|
|
29
30
|
*/
|
|
30
31
|
/** A person of a door as the run's visitor: a hash, never the number or the account itself. */
|
|
31
32
|
function visitorOf(person) {
|
|
32
|
-
return
|
|
33
|
+
return `${CHANNEL_VISITOR}${createHash("sha256").update(`${person.channel}:${person.id}`).digest("hex").slice(0, 32)}`;
|
|
33
34
|
}
|
|
34
35
|
export function runsApiFor(pluginId) {
|
|
35
36
|
return {
|
|
@@ -144,7 +144,7 @@ type List = {
|
|
|
144
144
|
|
|
145
145
|
type Connection =
|
|
146
146
|
| { id, kind: "mail", title?, description? }
|
|
147
|
-
// the person picks how to connect
|
|
147
|
+
// the person picks how to connect, from the mail connectors listed below that connect here; steps only ever READ it
|
|
148
148
|
| { id, spaceConnection: spaceConnectionId, actions?: actionId[], title?, description? }
|
|
149
149
|
// a connection of the SPACE (listed below), set up by its admins, who chose how it signs in, who may use it and
|
|
150
150
|
// what each kind of action may do; the wizard holds no account and "policy" has no say. Where it signs in as
|
|
@@ -706,8 +706,18 @@ Connectors a wizard of this space can use (built in, or imported from the integr
|
|
|
706
706
|
${connectors}
|
|
707
707
|
|
|
708
708
|
<!-- section: line.connectors.not_set_up -->
|
|
709
|
-
<!-- After a connector's name, behind " — ", when people cannot connect an account on this server. -->
|
|
710
|
-
|
|
709
|
+
<!-- After a connector's name, behind " — ", when people cannot connect an account on this server; line.connectors.settings may follow. -->
|
|
710
|
+
CAN'T CONNECT on this server yet: don't build on it, and don't name it as a way to connect
|
|
711
|
+
|
|
712
|
+
<!-- section: line.connectors.settings -->
|
|
713
|
+
<!-- After line.connectors.not_set_up where the settings are known; settings: the environment variables, comma-separated. -->
|
|
714
|
+
(the server's owner sets ${settings})
|
|
715
|
+
|
|
716
|
+
<!-- section: line.connectors.mail -->
|
|
717
|
+
<!-- connectors: one "- name" line per connector behind kind "mail", with line.connectors.not_set_up where it can't connect. -->
|
|
718
|
+
A connection of kind "mail" connects a mailbox here with these connectors; the person picks one:
|
|
719
|
+
${connectors}
|
|
720
|
+
Name only connectors that connect here: a title, label or description that says Gmail where only IMAP connects promises what the page can't do. Where the wish names a service that can't connect here yet (a mail provider above, or a connector marked CAN'T CONNECT), build with what connects, and tell the person in your reply that this service can't connect here yet and what the server's owner sets for it.
|
|
711
721
|
|
|
712
722
|
<!-- section: line.connectors.no_actions -->
|
|
713
723
|
actions appear once an account is connected
|
|
@@ -109,11 +109,6 @@ Skills of the space (Sources → Skills): instructions its wizards follow, alway
|
|
|
109
109
|
<!-- section: turn.skills_empty -->
|
|
110
110
|
The person talks to you from Skills, which is empty: skills are instructions the wizards follow. They are written, uploaded or added from skills.sh on that page.
|
|
111
111
|
|
|
112
|
-
<!-- "missing": what the studio lacks, a list the code makes. -->
|
|
113
|
-
|
|
114
|
-
<!-- section: turn.off -->
|
|
115
|
-
Not in this studio (no tools for it; never offer it): ${missing}.
|
|
116
|
-
|
|
117
112
|
<!-- What the person wrote while a turn was running, before its next step; "messages" joined by a blank line. -->
|
|
118
113
|
|
|
119
114
|
<!-- section: signal -->
|
|
@@ -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());
|