@fungi.computer/oyster 0.28.0 → 0.28.2
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/apps/gate.js +10 -7
- package/dist/apps/installation.d.ts +23 -2
- package/dist/apps/installation.js +66 -11
- package/dist/apps/operations.d.ts +5 -0
- package/dist/apps/operations.js +49 -10
- package/dist/apps/permissions.d.ts +23 -7
- package/dist/apps/permissions.js +5 -1
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +2 -2
- package/dist/host.js +7 -2
- package/dist/installation-migration.d.ts +5 -0
- package/dist/installation-migration.js +78 -0
- package/dist/installation-operations.d.ts +8 -0
- package/dist/installation-operations.js +2 -0
- package/dist/page-script.js +3 -3
- package/dist/standalone/workflow-host.d.ts +5 -0
- package/dist/workers.js +2 -0
- package/docs/api/apps.md +87 -73
- package/docs/api/git.md +3 -3
- package/docs/api/host.md +6 -0
- package/docs/api/mcp.md +16 -16
- package/docs/api/workers.md +54 -44
- package/package.json +11 -11
package/dist/host.js
CHANGED
|
@@ -17,7 +17,7 @@ import { match } from "path-to-regexp";
|
|
|
17
17
|
import * as Schema from "effect/Schema";
|
|
18
18
|
import * as Result from "effect/Result";
|
|
19
19
|
import { emptyAppDeclaration } from "@fungi.computer/puffball/app";
|
|
20
|
-
import { applyInstallationCommand, installationIdSchema, } from "./apps/installation.js";
|
|
20
|
+
import { applyInstallationCommand, carryGrant, installationIdSchema, } from "./apps/installation.js";
|
|
21
21
|
import { admits, scopedBindings, grantsFor } from "./apps/gate.js";
|
|
22
22
|
import { appCallTargetName, appPermissionPageSchema, permissionSaveSchema, } from "./apps/permissions.js";
|
|
23
23
|
import { app as appRoute, apps as appsRoute, door, member, oysterPrincipalIsOwner, owner, publicRoute, authorityOf, hostAuthorityPorts, reachesInstallation, routes, serveCapability, serveHost, } from "./authorization.js";
|
|
@@ -723,7 +723,12 @@ export function oysterRouteTable(host) {
|
|
|
723
723
|
]
|
|
724
724
|
: await host.permissionResources(principal),
|
|
725
725
|
permissions: {
|
|
726
|
-
|
|
726
|
+
// Show only approvals the declaration still covers; a changed
|
|
727
|
+
// operation needs approval again, as a new one does.
|
|
728
|
+
authority: {
|
|
729
|
+
...current.authority,
|
|
730
|
+
approvedGrants: current.authority.approvedGrants.map((grant) => carryGrant(grant, declared)),
|
|
731
|
+
},
|
|
727
732
|
declaredOperations: declared,
|
|
728
733
|
},
|
|
729
734
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WatchdogSqliteOwner } from "@fungi.computer/watchdog";
|
|
2
|
+
/** Rewrite every stored installation to the current approval contract, once. */
|
|
3
|
+
export declare function migrateInstallationRows(owner: WatchdogSqliteOwner): void;
|
|
4
|
+
/** Retained commands and provisional outcomes embed installations; migrate them alike. */
|
|
5
|
+
export declare function migrateCommandRows(owner: WatchdogSqliteOwner): void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { approvedGrantSchema, unstampedFingerprint, } from "./apps/installation.js";
|
|
4
|
+
/** An approved grant as Oyster 0.28 and earlier stored it, before fingerprints. */
|
|
5
|
+
const legacyGrantSchema = approvedGrantSchema
|
|
6
|
+
.unwrap()
|
|
7
|
+
.omit({ fingerprints: true })
|
|
8
|
+
.transform((grant) => ({
|
|
9
|
+
...grant,
|
|
10
|
+
fingerprints: Object.fromEntries(grant.operations.map((operation) => [operation, unstampedFingerprint])),
|
|
11
|
+
}));
|
|
12
|
+
/** A grant already in the current shape fails the strict legacy schema and is kept. */
|
|
13
|
+
const grantSchema = z.union([legacyGrantSchema, z.unknown()]);
|
|
14
|
+
const installationSchema = z.looseObject({
|
|
15
|
+
authority: z.looseObject({ approvedGrants: z.array(grantSchema) }),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* The one migration step for stored installations: grants written before
|
|
19
|
+
* fingerprints gain `unstampedFingerprint` for each approved operation, which
|
|
20
|
+
* the first release snapshot replaces. Stored approvals keep working and the
|
|
21
|
+
* old shape disappears from storage. Anything else passes through unchanged.
|
|
22
|
+
*/
|
|
23
|
+
const migrateInstallation = z.union([installationSchema, z.unknown()]);
|
|
24
|
+
/** A retained command: its baseline and planned installation. */
|
|
25
|
+
const commandSchema = z.looseObject({
|
|
26
|
+
baseline: migrateInstallation.optional(),
|
|
27
|
+
plan: z.looseObject({ installation: migrateInstallation }).nullish(),
|
|
28
|
+
});
|
|
29
|
+
/** A provisional outcome: the installation a command reported. */
|
|
30
|
+
const outcomeSchema = z.looseObject({
|
|
31
|
+
installation: migrateInstallation.optional(),
|
|
32
|
+
});
|
|
33
|
+
const installationRowSchema = z.strictObject({
|
|
34
|
+
installation_id: z.string(),
|
|
35
|
+
record: z.string(),
|
|
36
|
+
});
|
|
37
|
+
const commandRowSchema = z.strictObject({
|
|
38
|
+
request_id: z.string(),
|
|
39
|
+
command: z.string(),
|
|
40
|
+
provisional_outcome: z.string().nullable(),
|
|
41
|
+
});
|
|
42
|
+
/** Re-encode stored JSON (the query admits only valid JSON); null unless the migration changed it. */
|
|
43
|
+
function reencode(text, schema) {
|
|
44
|
+
const stored = JSON.parse(text);
|
|
45
|
+
const migrated = schema.safeParse(stored);
|
|
46
|
+
return migrated.success && !isDeepStrictEqual(stored, migrated.data)
|
|
47
|
+
? JSON.stringify(migrated.data)
|
|
48
|
+
: null;
|
|
49
|
+
}
|
|
50
|
+
/** Rewrite every stored installation to the current approval contract, once. */
|
|
51
|
+
export function migrateInstallationRows(owner) {
|
|
52
|
+
owner.transactionSync(() => {
|
|
53
|
+
for (const row of owner.sql
|
|
54
|
+
.exec("SELECT installation_id, record FROM installations WHERE json_valid(record)")
|
|
55
|
+
.toArray()) {
|
|
56
|
+
const { installation_id, record } = installationRowSchema.parse(row);
|
|
57
|
+
const next = reencode(record, installationSchema);
|
|
58
|
+
if (next !== null)
|
|
59
|
+
owner.sql.exec("UPDATE installations SET record=? WHERE installation_id=?", next, installation_id);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Retained commands and provisional outcomes embed installations; migrate them alike. */
|
|
64
|
+
export function migrateCommandRows(owner) {
|
|
65
|
+
owner.transactionSync(() => {
|
|
66
|
+
for (const row of owner.sql
|
|
67
|
+
.exec("SELECT request_id, command, provisional_outcome FROM installation_commands WHERE json_valid(command) AND (provisional_outcome IS NULL OR json_valid(provisional_outcome))")
|
|
68
|
+
.toArray()) {
|
|
69
|
+
const { request_id, command, provisional_outcome } = commandRowSchema.parse(row);
|
|
70
|
+
const nextCommand = reencode(command, commandSchema);
|
|
71
|
+
const nextOutcome = provisional_outcome === null
|
|
72
|
+
? null
|
|
73
|
+
: reencode(provisional_outcome, outcomeSchema);
|
|
74
|
+
if (nextCommand !== null || nextOutcome !== null)
|
|
75
|
+
owner.sql.exec("UPDATE installation_commands SET command=?, provisional_outcome=? WHERE request_id=?", nextCommand ?? command, nextOutcome ?? provisional_outcome, request_id);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -35,6 +35,7 @@ declare const installationOutcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
35
35
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
36
36
|
capabilityApproved: z.ZodLiteral<true>;
|
|
37
37
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
38
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
38
39
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
39
40
|
kind: z.ZodString;
|
|
40
41
|
id: z.ZodString;
|
|
@@ -254,6 +255,7 @@ export declare const installationOperationSchema: z.ZodDiscriminatedUnion<[z.Zod
|
|
|
254
255
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
255
256
|
capabilityApproved: z.ZodLiteral<true>;
|
|
256
257
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
258
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
257
259
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
258
260
|
kind: z.ZodString;
|
|
259
261
|
id: z.ZodString;
|
|
@@ -436,6 +438,7 @@ export declare const retainedInstallationCommandSchema: z.ZodObject<{
|
|
|
436
438
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
437
439
|
capabilityApproved: z.ZodLiteral<true>;
|
|
438
440
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
441
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
439
442
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
440
443
|
kind: z.ZodString;
|
|
441
444
|
id: z.ZodString;
|
|
@@ -497,6 +500,7 @@ export declare const retainedInstallationCommandSchema: z.ZodObject<{
|
|
|
497
500
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
498
501
|
capabilityApproved: z.ZodLiteral<true>;
|
|
499
502
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
503
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
500
504
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
501
505
|
kind: z.ZodString;
|
|
502
506
|
id: z.ZodString;
|
|
@@ -721,6 +725,7 @@ declare const installationOperationRequestSchema: z.ZodDiscriminatedUnion<[z.Zod
|
|
|
721
725
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
722
726
|
capabilityApproved: z.ZodLiteral<true>;
|
|
723
727
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
728
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
724
729
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
725
730
|
kind: z.ZodString;
|
|
726
731
|
id: z.ZodString;
|
|
@@ -941,6 +946,7 @@ declare const installationOperationReplySchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
941
946
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
942
947
|
capabilityApproved: z.ZodLiteral<true>;
|
|
943
948
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
949
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
944
950
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
945
951
|
kind: z.ZodString;
|
|
946
952
|
id: z.ZodString;
|
|
@@ -1085,6 +1091,7 @@ declare const installationOperationReplySchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
1085
1091
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
1086
1092
|
capabilityApproved: z.ZodLiteral<true>;
|
|
1087
1093
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
1094
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1088
1095
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
1089
1096
|
kind: z.ZodString;
|
|
1090
1097
|
id: z.ZodString;
|
|
@@ -1146,6 +1153,7 @@ declare const installationOperationReplySchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
1146
1153
|
capability: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage", unknown>>;
|
|
1147
1154
|
capabilityApproved: z.ZodLiteral<true>;
|
|
1148
1155
|
operations: z.ZodLazy<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
1156
|
+
fingerprints: z.ZodLazy<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1149
1157
|
resources: z.ZodUnion<readonly [z.ZodLiteral<"tenant-scope">, z.ZodReadonly<z.ZodArray<z.ZodLazy<z.ZodReadonly<z.ZodObject<{
|
|
1150
1158
|
kind: z.ZodString;
|
|
1151
1159
|
id: z.ZodString;
|
|
@@ -6,6 +6,7 @@ import { releaseSchema } from "@fungi.computer/puffball/effect";
|
|
|
6
6
|
import { hostActorSchema } from "@fungi.computer/puffball/app-method-runtime";
|
|
7
7
|
import { installationIdSchema, installationSchema, isCommittedInstallation, ownerCodec, } from "./apps/installation.js";
|
|
8
8
|
import { instanceIds, instanceIdSchema } from "./instance-id.js";
|
|
9
|
+
import { migrateCommandRows } from "./installation-migration.js";
|
|
9
10
|
import { tenantIdSchema, tenantScope } from "./tenant.js";
|
|
10
11
|
import { failureDiagnostic } from "./cause-class.js";
|
|
11
12
|
import { uiBootCheckOutcomeSchema, } from "./boot-gate.js";
|
|
@@ -352,6 +353,7 @@ export async function createInstallationOperations(ports) {
|
|
|
352
353
|
owner.sql.exec(`CREATE INDEX IF NOT EXISTS installation_commands_retention
|
|
353
354
|
ON installation_commands(retention_due_at)
|
|
354
355
|
WHERE retention_due_at IS NOT NULL`);
|
|
356
|
+
migrateCommandRows(owner);
|
|
355
357
|
const load = (requestId) => {
|
|
356
358
|
const row = owner.sql
|
|
357
359
|
.exec("SELECT command,provisional_outcome FROM installation_commands WHERE request_id=?", requestId)
|