@fungi.computer/oyster 0.35.0 → 0.36.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/dist/boot-host-script.js +1 -1
- package/dist/build/candidate-cli.mjs +5 -0
- package/dist/cloudflare.js +1 -0
- package/dist/embed-metafiles.js +2 -2
- package/dist/embed-scripts.js +1 -1
- package/dist/host.d.ts +3 -1
- package/dist/host.js +8 -8
- package/dist/internal/delivery.js +1 -1
- package/dist/invocation.d.ts +27 -5
- package/dist/invocation.js +9 -7
- package/dist/mcp.d.ts +3 -3
- package/dist/mcp.js +1 -1
- package/dist/page-script.js +2 -2
- package/dist/standalone/workflow-git-capture.d.ts +1 -1
- package/dist/standalone/workflow-git-capture.js +1 -1
- package/dist/standalone/workflow-host.d.ts +9 -2
- package/dist/standalone/workflow-host.js +21 -3
- package/dist/standalone/workflow-node-capture.d.ts +1 -1
- package/dist/standalone/workflow-node-capture.js +1 -1
- package/dist/standalone/workflow-trigger-host.d.ts +1 -1
- package/dist/testing/capabilities.js +2 -0
- package/dist/testing/worker.js +1 -0
- package/dist/workers-git.js +2 -1
- package/dist/workers.js +5 -0
- package/docs/api/host.md +1 -0
- package/docs/api/invocation.md +135 -97
- package/docs/api/mcp.md +5 -5
- package/docs/api/workers-git.md +180 -179
- package/docs/api/workers.md +217 -215
- package/package.json +17 -17
|
@@ -2,6 +2,6 @@ import type { WorkflowCeilingCapturePorts } from "@fungi.computer/braid/runtime"
|
|
|
2
2
|
import type { StandaloneWorkflowNodeCaptureOptions } from "./workflow-node-capture.js";
|
|
3
3
|
/** Installation Git only; Team-source needs its separate authoritative namespace owner. */
|
|
4
4
|
export declare function createStandaloneWorkflowInstallationGitCapture(options: Readonly<{
|
|
5
|
-
host: Pick<StandaloneWorkflowNodeCaptureOptions["host"], "auth" | "artifacts" | "installations">;
|
|
5
|
+
host: Pick<StandaloneWorkflowNodeCaptureOptions["host"], "tenantId" | "auth" | "artifacts" | "installations">;
|
|
6
6
|
readers: Pick<StandaloneWorkflowNodeCaptureOptions["readers"], "member">;
|
|
7
7
|
}>): WorkflowCeilingCapturePorts["git"];
|
|
@@ -17,7 +17,7 @@ export function createStandaloneWorkflowInstallationGitCapture(options) {
|
|
|
17
17
|
const principal = await host.auth.resolve(actor);
|
|
18
18
|
if (principal === null || !oysterPrincipalIsOwner(principal))
|
|
19
19
|
return false;
|
|
20
|
-
const caller = invocationCallerContext(principal, null);
|
|
20
|
+
const caller = invocationCallerContext(principal, null, host.tenantId);
|
|
21
21
|
if (caller.actor.kind !== "member" ||
|
|
22
22
|
caller.actor.memberId !== actor.memberId)
|
|
23
23
|
return false;
|
|
@@ -2,11 +2,11 @@ import * as S from "effect/Schema";
|
|
|
2
2
|
import { type Catalog, type DispatchResult, type NodeAdmissionResult, type NodeCall, type NodeEvent } from "@fungi.computer/braid";
|
|
3
3
|
import { type OysterHost } from "../host.js";
|
|
4
4
|
import { type InvocationFacts } from "../invocation.js";
|
|
5
|
-
import type
|
|
5
|
+
import { type AppMethodCallContext } from "@fungi.computer/puffball/app-method-runtime";
|
|
6
6
|
import type { WatchdogSqliteOwner } from "@fungi.computer/watchdog";
|
|
7
7
|
import { type GraphStartRequest, type WorkflowCatalogEntry, type WorkflowRunAuthority, type WorkflowGitPassNode, type WorkflowRunDelivery } from "@fungi.computer/braid/runtime";
|
|
8
8
|
import { type AppEventFact } from "@fungi.computer/puffball/app-event-facts";
|
|
9
|
-
export type StandaloneWorkflowHost = Pick<OysterHost, "installations" | "artifacts" | "instances" | "computerId" | "git" | "capabilities" | "keys">;
|
|
9
|
+
export type StandaloneWorkflowHost = Pick<OysterHost, "tenantId" | "installations" | "artifacts" | "instances" | "computerId" | "git" | "capabilities" | "keys">;
|
|
10
10
|
type CatalogMethodSummary = Readonly<{
|
|
11
11
|
pending?: true;
|
|
12
12
|
description: string;
|
|
@@ -150,6 +150,13 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
|
|
|
150
150
|
}>;
|
|
151
151
|
admitInvocation: (raw: InvocationFacts, operation: string) => Promise<{
|
|
152
152
|
context: {
|
|
153
|
+
scope: {
|
|
154
|
+
kind: "team";
|
|
155
|
+
teamId: string;
|
|
156
|
+
} | {
|
|
157
|
+
kind: "standalone";
|
|
158
|
+
tenant: string;
|
|
159
|
+
};
|
|
153
160
|
computerId: string | null;
|
|
154
161
|
actor: {
|
|
155
162
|
kind: "member";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as S from "effect/Schema";
|
|
2
|
+
import * as z from "zod/mini";
|
|
3
|
+
import { defaultTenant } from "../tenant.js";
|
|
2
4
|
import { admitRunInput, accepts, catalogEvents, catalogMethods, catalogSchema, contentDigest, canonicalJson, parseProjection, nodeEventSchema, } from "@fungi.computer/braid";
|
|
3
5
|
import { deriveDeclaredOperations, approvedBindingGrants, grantsFor, } from "../apps/index.js";
|
|
4
6
|
import { pendingSchema, presentMethodName, } from "@fungi.computer/agar/backend-definition";
|
|
@@ -7,6 +9,7 @@ import { verifyRelease, } from "../host.js";
|
|
|
7
9
|
import { APP_INVOCATION_CEILING_MS, invocationAuthorityOf, invocationFacts, invocationFactsSchema, } from "../invocation.js";
|
|
8
10
|
import { AppInstanceError } from "../index.js";
|
|
9
11
|
import { appCapabilityIds } from "@fungi.computer/puffball";
|
|
12
|
+
import { appMethodCallerSchema, } from "@fungi.computer/puffball/app-method-runtime";
|
|
10
13
|
import { createGraphWorkflowRuns, createTriggerRunReservations, compileForMember, graphStartRequestSchema, preparationFromRun, planNodeCall, workflowRunContextSchema, } from "@fungi.computer/braid/runtime";
|
|
11
14
|
import { appMethodCallContextSchema } from "@fungi.computer/puffball/app";
|
|
12
15
|
import { appEventFactSchema, } from "@fungi.computer/puffball/app-event-facts";
|
|
@@ -97,6 +100,10 @@ const summarizedEntry = (entry) => {
|
|
|
97
100
|
};
|
|
98
101
|
/** The standalone host's installation admission, above the portable engine. */
|
|
99
102
|
export function createStandaloneWorkflowHost(owner, host, options) {
|
|
103
|
+
// StandaloneWorkflows opens only the default tenant's durable namespace.
|
|
104
|
+
// A different host cannot relabel its existing stored caller attribution.
|
|
105
|
+
if (host.tenantId !== defaultTenant)
|
|
106
|
+
throw new AppInstanceError("installation_tenant_mismatch");
|
|
100
107
|
const graph = createGraphWorkflowRuns(owner);
|
|
101
108
|
const reservations = createTriggerRunReservations(owner);
|
|
102
109
|
const store = {
|
|
@@ -115,6 +122,11 @@ export function createStandaloneWorkflowHost(owner, host, options) {
|
|
|
115
122
|
owner.sql.exec(`CREATE TABLE IF NOT EXISTS standalone_workflow_callers (
|
|
116
123
|
run_id TEXT PRIMARY KEY, caller TEXT NOT NULL
|
|
117
124
|
) STRICT`);
|
|
125
|
+
// Store attribution, not a second tenant authority. Reconstruct scope from
|
|
126
|
+
// this host's pin on every read; the persisted caller representation stays
|
|
127
|
+
// unchanged and cannot choose another tenant.
|
|
128
|
+
const storedCallerSchema = z.omit(appMethodCallerSchema, { scope: true });
|
|
129
|
+
const encodeCaller = (context) => JSON.stringify(storedCallerSchema.parse(context));
|
|
118
130
|
const readCaller = (runId) => {
|
|
119
131
|
const row = owner.sql
|
|
120
132
|
.exec("SELECT caller FROM standalone_workflow_callers WHERE run_id=?", runId)
|
|
@@ -122,7 +134,10 @@ export function createStandaloneWorkflowHost(owner, host, options) {
|
|
|
122
134
|
if (row === undefined)
|
|
123
135
|
return null;
|
|
124
136
|
const saved = S.decodeUnknownSync(S.Struct({ caller: S.String }))(row);
|
|
125
|
-
return S.decodeUnknownSync(appMethodCallContextSchema)(
|
|
137
|
+
return S.decodeUnknownSync(appMethodCallContextSchema)({
|
|
138
|
+
...storedCallerSchema.parse(JSON.parse(saved.caller)),
|
|
139
|
+
scope: { kind: "standalone", tenant: host.tenantId },
|
|
140
|
+
});
|
|
126
141
|
};
|
|
127
142
|
const caller = (runId) => {
|
|
128
143
|
const saved = readCaller(runId);
|
|
@@ -277,6 +292,7 @@ export function createStandaloneWorkflowHost(owner, host, options) {
|
|
|
277
292
|
if (current.membershipVersion !== member.membershipVersion)
|
|
278
293
|
throw new AppInstanceError("revoked");
|
|
279
294
|
const context = {
|
|
295
|
+
scope: { kind: "standalone", tenant: host.tenantId },
|
|
280
296
|
actor: { kind: "member", memberId: member.memberId },
|
|
281
297
|
role: "owner",
|
|
282
298
|
computerId: host.computerId ?? null,
|
|
@@ -451,11 +467,12 @@ export function createStandaloneWorkflowHost(owner, host, options) {
|
|
|
451
467
|
/** Trigger runs act as the owner who armed them on their pinned Computer. */
|
|
452
468
|
recordTriggerCaller(runId, memberId, computerId) {
|
|
453
469
|
const context = {
|
|
470
|
+
scope: { kind: "standalone", tenant: host.tenantId },
|
|
454
471
|
actor: { kind: "member", memberId },
|
|
455
472
|
computerId,
|
|
456
473
|
role: "owner",
|
|
457
474
|
};
|
|
458
|
-
owner.sql.exec("INSERT OR IGNORE INTO standalone_workflow_callers(run_id,caller) VALUES(?,?)", runId,
|
|
475
|
+
owner.sql.exec("INSERT OR IGNORE INTO standalone_workflow_callers(run_id,caller) VALUES(?,?)", runId, encodeCaller(context));
|
|
459
476
|
},
|
|
460
477
|
catalog,
|
|
461
478
|
// Host readers use this only after admitting the live member and library.
|
|
@@ -617,6 +634,7 @@ export function createStandaloneWorkflowHost(owner, host, options) {
|
|
|
617
634
|
if (publication !== undefined && !(await publisherGranted(current)))
|
|
618
635
|
return { error: "not_granted" };
|
|
619
636
|
const callContext = {
|
|
637
|
+
scope: { kind: "standalone", tenant: host.tenantId },
|
|
620
638
|
actor: captured.actor,
|
|
621
639
|
computerId: context.computerId,
|
|
622
640
|
};
|
|
@@ -648,7 +666,7 @@ export function createStandaloneWorkflowHost(owner, host, options) {
|
|
|
648
666
|
// store compares the whole stored record, source and initiator included.
|
|
649
667
|
const accepted = store.startCompiled(run);
|
|
650
668
|
if (accepted !== "conflict")
|
|
651
|
-
owner.sql.exec("INSERT OR IGNORE INTO standalone_workflow_callers(run_id,caller) VALUES(?,?)", runId,
|
|
669
|
+
owner.sql.exec("INSERT OR IGNORE INTO standalone_workflow_callers(run_id,caller) VALUES(?,?)", runId, encodeCaller(callContext));
|
|
652
670
|
return accepted;
|
|
653
671
|
});
|
|
654
672
|
return { kind, runId, planDigest: compiled.plan.planDigest };
|
|
@@ -3,7 +3,7 @@ import { type OysterHost } from "../host.js";
|
|
|
3
3
|
import type { StandaloneWorkflowAuthorityReaders } from "./workflow-authority-readers.js";
|
|
4
4
|
/** Live host readers and approvals; a compile catalog is deliberately not a grant port. */
|
|
5
5
|
export type StandaloneWorkflowNodeCaptureOptions = Readonly<{
|
|
6
|
-
host: Pick<OysterHost, "artifacts" | "computerId" | "capabilities"> & Readonly<{
|
|
6
|
+
host: Pick<OysterHost, "tenantId" | "artifacts" | "computerId" | "capabilities"> & Readonly<{
|
|
7
7
|
auth: Pick<OysterHost["auth"], "resolve">;
|
|
8
8
|
installations: Pick<OysterHost["installations"], "get">;
|
|
9
9
|
}>;
|
|
@@ -19,7 +19,7 @@ export function createStandaloneWorkflowNodeCapture(options) {
|
|
|
19
19
|
const principal = await host.auth.resolve(actor);
|
|
20
20
|
if (principal === null || !oysterPrincipalIsOwner(principal))
|
|
21
21
|
return null;
|
|
22
|
-
const caller = invocationCallerContext(principal, target.computerId);
|
|
22
|
+
const caller = invocationCallerContext(principal, target.computerId, host.tenantId);
|
|
23
23
|
if (caller.actor.kind !== "member" ||
|
|
24
24
|
caller.actor.memberId !== actor.memberId)
|
|
25
25
|
return null;
|
|
@@ -27,9 +27,9 @@ export declare function createStandaloneWorkflowTriggerHost(options: {
|
|
|
27
27
|
readonly [x: string]: import("effect/Schema").Json;
|
|
28
28
|
};
|
|
29
29
|
readonly source: "key" | "manual" | "event" | "schedule" | "agent";
|
|
30
|
+
readonly teamId: string;
|
|
30
31
|
readonly runId: string;
|
|
31
32
|
readonly computerId: string | null;
|
|
32
|
-
readonly teamId: string;
|
|
33
33
|
readonly plan: {
|
|
34
34
|
readonly planDigest: string;
|
|
35
35
|
readonly definition: {
|
|
@@ -10,6 +10,7 @@ import { createOyster, } from "../host.js";
|
|
|
10
10
|
import { instanceIds } from "../index.js";
|
|
11
11
|
import { sha256, verifyRelease } from "../release.js";
|
|
12
12
|
import { approvedInstallation } from "./installation.js";
|
|
13
|
+
import { defaultTenant } from "../tenant.js";
|
|
13
14
|
/** One Oyster host with a single installation whose capability grants the options shape. */
|
|
14
15
|
export async function capabilityFixture(options = {}) {
|
|
15
16
|
const artifacts = new Map();
|
|
@@ -83,6 +84,7 @@ export async function capabilityFixture(options = {}) {
|
|
|
83
84
|
};
|
|
84
85
|
const readOnly = () => Promise.reject(new Error("Fixture installations are read-only"));
|
|
85
86
|
let base = {
|
|
87
|
+
tenantId: defaultTenant,
|
|
86
88
|
bootUi: () => Promise.resolve({ kind: "passed" }),
|
|
87
89
|
auth: {
|
|
88
90
|
resolve: () => Promise.reject(new Error("Capability fixture resolves no actor")),
|
package/dist/testing/worker.js
CHANGED
package/dist/workers-git.js
CHANGED
|
@@ -966,7 +966,7 @@ export function oysterWorkerGit(env, options, frame) {
|
|
|
966
966
|
const installations = registryInstallations(env, scope);
|
|
967
967
|
const git = {
|
|
968
968
|
writerOf: (who) => {
|
|
969
|
-
const context = invocationCallerContext(who, null);
|
|
969
|
+
const context = invocationCallerContext(who, null, scope.tenantId);
|
|
970
970
|
return context.actor.kind === "member" && context.role !== undefined
|
|
971
971
|
? { kind: "actor", actor: context.actor, role: context.role }
|
|
972
972
|
: { kind: "actor", actor: context.actor };
|
|
@@ -1047,6 +1047,7 @@ export function oysterWorkerGit(env, options, frame) {
|
|
|
1047
1047
|
throw new AppInstanceError("revoked");
|
|
1048
1048
|
const deadlineAt = Math.min(Date.now() + APP_INVOCATION_CEILING_MS, invocation?.facts.deadlineAt ?? Infinity);
|
|
1049
1049
|
const context = {
|
|
1050
|
+
scope: { kind: "standalone", tenant: scope.tenantId },
|
|
1050
1051
|
computerId: null,
|
|
1051
1052
|
actor: question.writer.actor,
|
|
1052
1053
|
};
|
package/dist/workers.js
CHANGED
|
@@ -1004,6 +1004,10 @@ export class OysterInstance extends DurableObject {
|
|
|
1004
1004
|
const facts = Schema.decodeUnknownSync(invocationFactsSchema, {
|
|
1005
1005
|
onExcessProperty: "error",
|
|
1006
1006
|
})(raw);
|
|
1007
|
+
if (facts.subject.kind === "call" &&
|
|
1008
|
+
(facts.subject.context.scope.kind !== "standalone" ||
|
|
1009
|
+
facts.subject.context.scope.tenant !== this.scope().tenantId))
|
|
1010
|
+
throw new AppInstanceError("installation_tenant_mismatch");
|
|
1007
1011
|
if (facts.instanceId !== this.ctx.id.name ||
|
|
1008
1012
|
facts.selection.owner.kind !== "installation" ||
|
|
1009
1013
|
facts.selection.owner.id !== this.installationId())
|
|
@@ -1292,6 +1296,7 @@ export function oysterWorkerHost(env, auth, options = {}) {
|
|
|
1292
1296
|
setAutoApprove: (input) => registry().approvalSetAutoApprove(pin, actor, input),
|
|
1293
1297
|
});
|
|
1294
1298
|
let host = {
|
|
1299
|
+
tenantId: scope.tenantId,
|
|
1295
1300
|
approvals: {
|
|
1296
1301
|
submit: async (call, signal) => {
|
|
1297
1302
|
const cancelled = () => signal.aborted;
|