@fungi.computer/oyster 0.16.0 → 0.17.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/agents.d.ts +7 -0
- package/dist/agents.js +4 -1
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +1 -1
- package/dist/page-script.js +1 -1
- package/dist/root-data.d.ts +3 -0
- package/dist/standalone/agents.d.ts +8 -0
- package/dist/standalone/agents.js +51 -12
- package/dist/standalone/owner-routes.js +2 -0
- package/dist/standalone/registry.d.ts +16 -0
- package/dist/standalone/registry.js +30 -0
- package/dist/standalone/trial-starters.d.ts +52 -0
- package/dist/standalone/trial-starters.js +67 -0
- package/dist/starter-agent.d.ts +10 -4
- package/dist/starter-agent.js +4 -4
- package/docs/api/agents.md +17 -0
- package/docs/api/host.md +1 -0
- package/docs/api/root-data.md +10 -9
- package/docs/api/workers-git.md +6 -6
- package/docs/api/workers.md +20 -17
- package/package.json +5 -5
package/dist/root-data.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Release } from "@fungi.computer/puffball";
|
|
2
2
|
import { createAppStorage } from "./app-storage.js";
|
|
3
3
|
import type { InstallationStore, verifyRelease } from "./host.js";
|
|
4
|
+
import type { InstallingApp } from "@fungi.computer/nacre/workbench-directory";
|
|
4
5
|
import { type AppDirectoryEntry } from "@fungi.computer/nacre/app-directory";
|
|
5
6
|
/**
|
|
6
7
|
* A destination the host offers the dashboard. This is a structural twin of
|
|
@@ -26,6 +27,8 @@ export type OysterRootDirectory = Readonly<{
|
|
|
26
27
|
computerId: string;
|
|
27
28
|
name: string;
|
|
28
29
|
}>;
|
|
30
|
+
/** Trial starter Apps still being set up; the registry adds them. */
|
|
31
|
+
installing?: readonly InstallingApp[];
|
|
29
32
|
}>;
|
|
30
33
|
/** Existing installation, Release and SQLite owners supplied by the root. */
|
|
31
34
|
export type OysterRootDataOptions = Parameters<typeof createAppStorage>[0] & Readonly<{
|
|
@@ -27,6 +27,7 @@ import { type AgentModelChoice, type AgentModelRefusal } from "./agent-model-cho
|
|
|
27
27
|
import * as Schema from "effect/Schema";
|
|
28
28
|
import { type FrameBindingProps } from "../cloudflare.js";
|
|
29
29
|
import { type AppAgentScheduleListInput, type AgentSchedulePage, type AgentScheduleTarget, type AgentScheduleControlReceipt } from "../agent-schedules.js";
|
|
30
|
+
import { type StarterLedgerRow } from "../starter-agent.js";
|
|
30
31
|
import type { Avatar } from "@fungi.computer/sprite/avatar";
|
|
31
32
|
import type { InvocationFrame } from "../invocation.js";
|
|
32
33
|
import type { OysterJson } from "../host.js";
|
|
@@ -445,6 +446,13 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
|
|
|
445
446
|
archived?: boolean;
|
|
446
447
|
}>): readonly AgentEntry[];
|
|
447
448
|
has(agentId: string): boolean;
|
|
449
|
+
private starterLedgerOwner;
|
|
450
|
+
private get starterLedger();
|
|
451
|
+
/** The starter Agent's one-row ledger and the Agent total it reads, for the owner's ensure. */
|
|
452
|
+
readStarter(): StarterLedgerRow | undefined;
|
|
453
|
+
recordStarter(row: StarterLedgerRow): void;
|
|
454
|
+
/** Every Agent in the directory, archived ones included. */
|
|
455
|
+
agentTotal(): number;
|
|
448
456
|
/** Resolve the existing recorded creator for host-side owner admission. */
|
|
449
457
|
readCreator(agentId: string): string | null;
|
|
450
458
|
/** Immutable creating Agent, distinct from the human credential owner. */
|
|
@@ -57,6 +57,7 @@ import { agentScheduleBindingArgs, appAgentScheduleListInputSchema, agentSchedul
|
|
|
57
57
|
import { readAgentSchedulePage, controlAgentSchedule, } from "@fungi.computer/shiitake-extensions/schedules/client";
|
|
58
58
|
import { agentScheduleTargetSchema } from "@fungi.computer/shiitake-extensions/schedules";
|
|
59
59
|
import { createAgentAvatarStore, } from "../agent-avatars.js";
|
|
60
|
+
import { createStarterLedger, ensureStarterAgent, } from "../starter-agent.js";
|
|
60
61
|
import { agentIds, createAgentDirectory, createFleetSessions, commandSettlementSchema, DirectoryError, } from "@fungi.computer/shiitake/fleet";
|
|
61
62
|
import { appToolPolicySchema, } from "../apps/index.js";
|
|
62
63
|
import { oysterPrincipalId } from "../host.js";
|
|
@@ -1689,6 +1690,21 @@ export class AgentDirectory extends DurableObject {
|
|
|
1689
1690
|
const id = agentIds.agent.parse(agentId);
|
|
1690
1691
|
return id.ok && this.directory.read(this.grant(), id.value) !== null;
|
|
1691
1692
|
}
|
|
1693
|
+
starterLedgerOwner;
|
|
1694
|
+
get starterLedger() {
|
|
1695
|
+
return (this.starterLedgerOwner ??= createStarterLedger(this.ctx.storage.sql));
|
|
1696
|
+
}
|
|
1697
|
+
/** The starter Agent's one-row ledger and the Agent total it reads, for the owner's ensure. */
|
|
1698
|
+
readStarter() {
|
|
1699
|
+
return this.starterLedger.read();
|
|
1700
|
+
}
|
|
1701
|
+
recordStarter(row) {
|
|
1702
|
+
this.starterLedger.record(row);
|
|
1703
|
+
}
|
|
1704
|
+
/** Every Agent in the directory, archived ones included. */
|
|
1705
|
+
agentTotal() {
|
|
1706
|
+
return this.directory.list(this.grant()).length;
|
|
1707
|
+
}
|
|
1692
1708
|
/** Resolve the existing recorded creator for host-side owner admission. */
|
|
1693
1709
|
readCreator(agentId) {
|
|
1694
1710
|
return this.directory.readCreator(this.grant(), agentId);
|
|
@@ -1970,6 +1986,20 @@ export function standaloneAgents(env, scope) {
|
|
|
1970
1986
|
avatar: entry.avatar,
|
|
1971
1987
|
sessionOperations: everyOperation,
|
|
1972
1988
|
});
|
|
1989
|
+
const created = async (name, requestId, principal, actor, avatar) => {
|
|
1990
|
+
const entry = await directory().create(name, requestId, principal, actor, avatar);
|
|
1991
|
+
await env.AGENTS.getByName(entry.agentId).usePolicyDirectory({
|
|
1992
|
+
directoryName,
|
|
1993
|
+
tenantId: scope?.tenantId ?? defaultTenant,
|
|
1994
|
+
});
|
|
1995
|
+
if (actor === "owner-direct" && entry.policyRevision !== null) {
|
|
1996
|
+
// Best-effort: a stale membership lookup leaves the Agent pending
|
|
1997
|
+
// rather than failing its creation. Grove's "Allow App tools"
|
|
1998
|
+
// control recovers it through the same approval path.
|
|
1999
|
+
await directory().approveAppToolPolicy(entry.agentId, principal, "write", entry.policyRevision, actor, scope?.tenantId ?? defaultTenant);
|
|
2000
|
+
}
|
|
2001
|
+
return toAgent(entry);
|
|
2002
|
+
};
|
|
1973
2003
|
return {
|
|
1974
2004
|
list: async (options) => (await directory().list(options)).map(toAgent),
|
|
1975
2005
|
setArchived: async (agentId, archived, principal) => {
|
|
@@ -1984,19 +2014,28 @@ export function standaloneAgents(env, scope) {
|
|
|
1984
2014
|
return { error: "not_found" };
|
|
1985
2015
|
return agent.setArchived(archived);
|
|
1986
2016
|
},
|
|
1987
|
-
create:
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2017
|
+
create: created,
|
|
2018
|
+
ensureStarter: (principal) => {
|
|
2019
|
+
const owner = directory();
|
|
2020
|
+
return ensureStarterAgent({
|
|
2021
|
+
ledger: {
|
|
2022
|
+
read: () => owner.readStarter(),
|
|
2023
|
+
record: (row) => owner.recordStarter(row),
|
|
2024
|
+
},
|
|
2025
|
+
isOwner: () => oysterPrincipalIsOwner(principal),
|
|
2026
|
+
agentCount: () => owner.agentTotal(),
|
|
2027
|
+
// The ordinary create: the same Computer-less Agent, policy and approval any owner create gets.
|
|
2028
|
+
create: async (request) => {
|
|
2029
|
+
const agent = await created(request.name, request.requestId, principal, "owner-direct");
|
|
2030
|
+
return { status: "created", agentId: agent.agentId };
|
|
2031
|
+
},
|
|
2032
|
+
report: (cause) => {
|
|
2033
|
+
console.warn(JSON.stringify({
|
|
2034
|
+
event: "starter_agent_failed",
|
|
2035
|
+
cause: String(cause),
|
|
2036
|
+
}));
|
|
2037
|
+
},
|
|
1992
2038
|
});
|
|
1993
|
-
if (actor === "owner-direct" && entry.policyRevision !== null) {
|
|
1994
|
-
// Best-effort: a stale membership lookup leaves the Agent pending
|
|
1995
|
-
// rather than failing its creation. Grove's "Allow App tools"
|
|
1996
|
-
// control recovers it through the same approval path.
|
|
1997
|
-
await directory().approveAppToolPolicy(entry.agentId, principal, "write", entry.policyRevision, actor, scope?.tenantId ?? defaultTenant);
|
|
1998
|
-
}
|
|
1999
|
-
return toAgent(entry);
|
|
2000
2039
|
},
|
|
2001
2040
|
rename: async (agentId, name, principal) => {
|
|
2002
2041
|
const result = await directory().rename(agentId, name, principal);
|
|
@@ -3,6 +3,7 @@ import { agentDirectoryForScope } from "./agent-directory.js";
|
|
|
3
3
|
import { standaloneAgentComputerRoutes } from "./agent-computers.js";
|
|
4
4
|
import { appSourceOwnerRoutes, } from "./app-source.js";
|
|
5
5
|
import { standaloneBuildRoutes } from "./builds.js";
|
|
6
|
+
import { trialStarterRoutes } from "./trial-starters.js";
|
|
6
7
|
import { standaloneComputerFleetRoutes } from "./computer-fleet.js";
|
|
7
8
|
import { standaloneWorkflowWebhookControls } from "./workflow-webhooks.js";
|
|
8
9
|
import { standaloneWebsiteControl, standaloneWebsiteRoutes, } from "./website-channels.js";
|
|
@@ -13,6 +14,7 @@ export function standaloneOwnerRoutes(env, scope, hostFor) {
|
|
|
13
14
|
const directory = () => agentDirectoryForScope(env, scope);
|
|
14
15
|
const owned = appSourceOwnerRoutes(env, scope)
|
|
15
16
|
.include(standaloneBuildRoutes(registry))
|
|
17
|
+
.include(trialStarterRoutes(registry))
|
|
16
18
|
.include(standaloneComputerFleetRoutes(registry))
|
|
17
19
|
.include(standaloneAgentComputerRoutes({
|
|
18
20
|
attach: (principal, command) => directory().attachComputer(command, principal, scope.tenantId),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Release } from "@fungi.computer/puffball";
|
|
2
2
|
import { OysterRegistry, type OysterWorkerEnv } from "../workers.js";
|
|
3
3
|
import { type OysterHost } from "../host.js";
|
|
4
|
+
import type { OysterRootDirectory } from "../root-data.js";
|
|
5
|
+
import type { InstallingApp } from "@fungi.computer/nacre/workbench-directory";
|
|
4
6
|
import { type TenantScope, type TenantId } from "../tenant.js";
|
|
5
7
|
import { type OysterGitEnv } from "../workers-git.js";
|
|
6
8
|
import { type AppSourceForkResult, type TemplateSeedClaim } from "../source/index.js";
|
|
@@ -45,6 +47,20 @@ export declare abstract class StandaloneRegistry extends OysterRegistry implemen
|
|
|
45
47
|
#private;
|
|
46
48
|
protected abstract hostFor(scope: TenantScope): Promise<OysterHost>;
|
|
47
49
|
constructor(state: DurableObjectState, env: StandaloneRegistryEnv, git?: StandaloneRegistryGit);
|
|
50
|
+
/** Starter Apps a trial is still setting up, cleared once each is installed. */
|
|
51
|
+
directory(): Promise<OysterRootDirectory>;
|
|
52
|
+
reportTrialStarters(installing: readonly InstallingApp[]): Promise<void>;
|
|
53
|
+
trialStartersList(): Promise<readonly {
|
|
54
|
+
installationId: string;
|
|
55
|
+
displayName: string;
|
|
56
|
+
state: "failed" | "installing" | "needs-runtime";
|
|
57
|
+
reason?: {
|
|
58
|
+
code: "unknown" | "build_failed" | "network" | "unsupported";
|
|
59
|
+
message: string;
|
|
60
|
+
} | undefined;
|
|
61
|
+
}[]>;
|
|
62
|
+
requestTrialRetry(installationId: string): Promise<boolean>;
|
|
63
|
+
takeTrialRetries(): Promise<readonly string[]>;
|
|
48
64
|
/** Whether installations or build jobs were written by Oyster 0.2 or earlier. */
|
|
49
65
|
storeFromOlderOyster(): boolean;
|
|
50
66
|
/** Re-admit the live owner before inventory access or a hosted start. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalJson } from "@fungi.computer/braid";
|
|
2
2
|
import { OysterRegistry, r2ArtifactStore, } from "../workers.js";
|
|
3
3
|
import { installOrSelect } from "../host.js";
|
|
4
|
+
import { createTrialStarters, pendingStarters } from "./trial-starters.js";
|
|
4
5
|
import { installationOperationsPort } from "../installation-operations.js";
|
|
5
6
|
import { tenantScope } from "../tenant.js";
|
|
6
7
|
import { artifactsOf } from "../workers-git.js";
|
|
@@ -33,11 +34,22 @@ export class StandaloneRegistry extends OysterRegistry {
|
|
|
33
34
|
#builds;
|
|
34
35
|
#computers;
|
|
35
36
|
#fleetStorage;
|
|
37
|
+
#trial;
|
|
36
38
|
constructor(state, env, git = {}) {
|
|
37
39
|
super(state, env);
|
|
38
40
|
this.#env = env;
|
|
39
41
|
this.#git = git;
|
|
40
42
|
this.#fleetStorage = state.storage;
|
|
43
|
+
this.#trial = createTrialStarters({
|
|
44
|
+
starters: {
|
|
45
|
+
read: () => state.storage.get("trial.starters"),
|
|
46
|
+
write: (value) => state.storage.put("trial.starters", value),
|
|
47
|
+
},
|
|
48
|
+
retries: {
|
|
49
|
+
read: () => state.storage.get("trial.retries"),
|
|
50
|
+
write: (value) => state.storage.put("trial.retries", value),
|
|
51
|
+
},
|
|
52
|
+
});
|
|
41
53
|
// Native hosts own infrastructure capacity. Standalone has no Team quota.
|
|
42
54
|
this.#computers = createFleetComputers(state.storage, {
|
|
43
55
|
limit: Number.MAX_SAFE_INTEGER,
|
|
@@ -45,6 +57,24 @@ export class StandaloneRegistry extends OysterRegistry {
|
|
|
45
57
|
});
|
|
46
58
|
this.#computers.ensure();
|
|
47
59
|
}
|
|
60
|
+
/** Starter Apps a trial is still setting up, cleared once each is installed. */
|
|
61
|
+
async directory() {
|
|
62
|
+
const base = await super.directory();
|
|
63
|
+
const installing = pendingStarters(await this.#trial.list(), base.apps.flatMap((app) => app.installationId === null ? [] : [app.installationId]));
|
|
64
|
+
return installing.length === 0 ? base : { ...base, installing };
|
|
65
|
+
}
|
|
66
|
+
async reportTrialStarters(installing) {
|
|
67
|
+
await this.#trial.report(installing);
|
|
68
|
+
}
|
|
69
|
+
trialStartersList() {
|
|
70
|
+
return this.#trial.list();
|
|
71
|
+
}
|
|
72
|
+
requestTrialRetry(installationId) {
|
|
73
|
+
return this.#trial.requestRetry(installationId);
|
|
74
|
+
}
|
|
75
|
+
takeTrialRetries() {
|
|
76
|
+
return this.#trial.takeRetries();
|
|
77
|
+
}
|
|
48
78
|
/** Whether installations or build jobs were written by Oyster 0.2 or earlier. */
|
|
49
79
|
storeFromOlderOyster() {
|
|
50
80
|
return (super.storeFromOlderOyster() ||
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { type InstallingApp } from "@fungi.computer/nacre/workbench-directory";
|
|
3
|
+
import { type Routes } from "../authorization.js";
|
|
4
|
+
import type { OysterEnv } from "../host.js";
|
|
5
|
+
import type { StandaloneRegistry } from "./registry.js";
|
|
6
|
+
/** What `oyster try` tells its Oyster about the starter Apps still being set up. */
|
|
7
|
+
export declare const trialStartersBodySchema: z.ZodObject<{
|
|
8
|
+
installing: z.ZodArray<z.ZodObject<{
|
|
9
|
+
installationId: z.ZodString;
|
|
10
|
+
displayName: z.ZodString;
|
|
11
|
+
state: z.ZodEnum<{
|
|
12
|
+
readonly installing: "installing";
|
|
13
|
+
readonly failed: "failed";
|
|
14
|
+
readonly "needs-runtime": "needs-runtime";
|
|
15
|
+
}>;
|
|
16
|
+
reason: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
code: z.ZodEnum<{
|
|
18
|
+
readonly build_failed: "build_failed";
|
|
19
|
+
readonly network: "network";
|
|
20
|
+
readonly unsupported: "unsupported";
|
|
21
|
+
readonly unknown: "unknown";
|
|
22
|
+
}>;
|
|
23
|
+
message: z.ZodString;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
}, z.core.$strict>>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
/** One typed record the registry keeps durably. */
|
|
28
|
+
export type TrialPort<T> = Readonly<{
|
|
29
|
+
read(): Promise<T | undefined>;
|
|
30
|
+
write(value: T): Promise<void>;
|
|
31
|
+
}>;
|
|
32
|
+
/** Where the trial's list and retry asks live. */
|
|
33
|
+
export type TrialStarterStorage = Readonly<{
|
|
34
|
+
starters: TrialPort<readonly InstallingApp[]>;
|
|
35
|
+
retries: TrialPort<readonly string[]>;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* The trial's starter-App state. `oyster try` replaces the list as each App
|
|
39
|
+
* settles; the desktop asks for a retry of one App and `try` takes the asks.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createTrialStarters(storage: TrialStarterStorage): {
|
|
42
|
+
list(): Promise<readonly InstallingApp[]>;
|
|
43
|
+
report(installing: readonly InstallingApp[]): Promise<readonly InstallingApp[]>;
|
|
44
|
+
/** Only a failed App can be retried; the ask is remembered until taken. */
|
|
45
|
+
requestRetry(installationId: string): Promise<boolean>;
|
|
46
|
+
takeRetries(): Promise<readonly string[]>;
|
|
47
|
+
};
|
|
48
|
+
/** Starters still listed once their App is installed no longer show as pending. */
|
|
49
|
+
export declare function pendingStarters(listed: readonly InstallingApp[], installedIds: readonly string[]): readonly InstallingApp[];
|
|
50
|
+
export type RegistryBinding = () => Pick<StandaloneRegistry, "reportTrialStarters" | "requestTrialRetry" | "takeTrialRetries" | "trialStartersList">;
|
|
51
|
+
/** Owner-key routes `oyster try` and the desktop use; the owner guard is declared per route. */
|
|
52
|
+
export declare function trialStarterRoutes(registry: RegistryBinding): Routes<OysterEnv>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { installingAppSchema, } from "@fungi.computer/nacre/workbench-directory";
|
|
3
|
+
import { owner, routes as routeTable } from "../authorization.js";
|
|
4
|
+
/** What `oyster try` tells its Oyster about the starter Apps still being set up. */
|
|
5
|
+
export const trialStartersBodySchema = z.strictObject({
|
|
6
|
+
installing: z.array(installingAppSchema).max(16),
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* The trial's starter-App state. `oyster try` replaces the list as each App
|
|
10
|
+
* settles; the desktop asks for a retry of one App and `try` takes the asks.
|
|
11
|
+
*/
|
|
12
|
+
export function createTrialStarters(storage) {
|
|
13
|
+
return {
|
|
14
|
+
async list() {
|
|
15
|
+
return (await storage.starters.read()) ?? [];
|
|
16
|
+
},
|
|
17
|
+
async report(installing) {
|
|
18
|
+
const parsed = trialStartersBodySchema.parse({ installing }).installing;
|
|
19
|
+
await storage.starters.write(parsed);
|
|
20
|
+
return parsed;
|
|
21
|
+
},
|
|
22
|
+
/** Only a failed App can be retried; the ask is remembered until taken. */
|
|
23
|
+
async requestRetry(installationId) {
|
|
24
|
+
const current = await this.list();
|
|
25
|
+
if (!current.some((entry) => entry.installationId === installationId && entry.state === "failed"))
|
|
26
|
+
return false;
|
|
27
|
+
const asks = (await storage.retries.read()) ?? [];
|
|
28
|
+
if (!asks.includes(installationId))
|
|
29
|
+
await storage.retries.write([...asks, installationId]);
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
async takeRetries() {
|
|
33
|
+
const asks = (await storage.retries.read()) ?? [];
|
|
34
|
+
if (asks.length > 0)
|
|
35
|
+
await storage.retries.write([]);
|
|
36
|
+
return asks;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Starters still listed once their App is installed no longer show as pending. */
|
|
41
|
+
export function pendingStarters(listed, installedIds) {
|
|
42
|
+
return listed.filter((entry) => !installedIds.includes(entry.installationId));
|
|
43
|
+
}
|
|
44
|
+
/** Owner-key routes `oyster try` and the desktop use; the owner guard is declared per route. */
|
|
45
|
+
export function trialStarterRoutes(registry) {
|
|
46
|
+
const routes = routeTable();
|
|
47
|
+
routes.put("/api/trial/starters", owner("direct"), async (context) => {
|
|
48
|
+
let body;
|
|
49
|
+
try {
|
|
50
|
+
body = await context.req.json();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return context.json({ kind: "invalid" }, 400);
|
|
54
|
+
}
|
|
55
|
+
const parsed = trialStartersBodySchema.safeParse(body);
|
|
56
|
+
if (!parsed.success)
|
|
57
|
+
return context.json({ kind: "invalid" }, 400);
|
|
58
|
+
await registry().reportTrialStarters(parsed.data.installing);
|
|
59
|
+
return new Response(null, { status: 204 });
|
|
60
|
+
});
|
|
61
|
+
routes.get("/api/trial/starters", owner("direct"), async () => Response.json({ installing: await registry().trialStartersList() }, { headers: { "Cache-Control": "no-store" } }));
|
|
62
|
+
routes.post("/api/trial/starters/:installationId/retry", owner("direct"), async (context) => (await registry().requestTrialRetry(context.req.param("installationId")))
|
|
63
|
+
? new Response(null, { status: 202 })
|
|
64
|
+
: context.json({ kind: "not_retryable" }, 409));
|
|
65
|
+
routes.post("/api/trial/starters/retries", owner("direct"), async () => Response.json({ retries: await registry().takeTrialRetries() }, { headers: { "Cache-Control": "no-store" } }));
|
|
66
|
+
return routes;
|
|
67
|
+
}
|
package/dist/starter-agent.d.ts
CHANGED
|
@@ -20,12 +20,17 @@ export type StarterLedgerRow = Readonly<{
|
|
|
20
20
|
agentId: string | null;
|
|
21
21
|
at: number;
|
|
22
22
|
}>;
|
|
23
|
-
/** One row per Team
|
|
24
|
-
export type
|
|
23
|
+
/** One row per Team in the host's own SQLite. */
|
|
24
|
+
export type StarterLedgerStore = Readonly<{
|
|
25
25
|
read(): StarterLedgerRow | undefined;
|
|
26
26
|
/** First write wins; a later one is ignored. */
|
|
27
27
|
record(row: StarterLedgerRow): void;
|
|
28
28
|
}>;
|
|
29
|
+
/** The ledger as the policy reads it; a host across an RPC awaits its store. */
|
|
30
|
+
export type StarterLedger = Readonly<{
|
|
31
|
+
read(): StarterLedgerRow | undefined | Promise<StarterLedgerRow | undefined>;
|
|
32
|
+
record(row: StarterLedgerRow): void | Promise<void>;
|
|
33
|
+
}>;
|
|
29
34
|
/** The host's ordinary create, as the starter sees it. */
|
|
30
35
|
export type StarterCreateResult = Readonly<{
|
|
31
36
|
status: "created";
|
|
@@ -38,7 +43,7 @@ export type StarterAgentHost = Readonly<{
|
|
|
38
43
|
/** Only the Team owner's read may trigger the starter. */
|
|
39
44
|
isOwner(): boolean;
|
|
40
45
|
/** Agents in the Team, archived ones included. */
|
|
41
|
-
agentCount(): number
|
|
46
|
+
agentCount(): number | Promise<number>;
|
|
42
47
|
/** The host's normal create, replayed by `requestId`; funding refusal is `unfunded`. */
|
|
43
48
|
create(request: {
|
|
44
49
|
name: string;
|
|
@@ -48,9 +53,10 @@ export type StarterAgentHost = Readonly<{
|
|
|
48
53
|
report?(cause: unknown): void;
|
|
49
54
|
now?(): number;
|
|
50
55
|
}>;
|
|
56
|
+
/** How one offer of the starter Agent settled; only `created` made an Agent. */
|
|
51
57
|
export type StarterOutcome = "created" | "already-offered" | "team-not-empty" | "unfunded" | "not-owner" | "failed";
|
|
52
58
|
/** Open the one-row ledger in the host's own SQLite. */
|
|
53
|
-
export declare function createStarterLedger(sql: WatchdogSqliteOwner["sql"]):
|
|
59
|
+
export declare function createStarterLedger(sql: WatchdogSqliteOwner["sql"]): StarterLedgerStore;
|
|
54
60
|
/**
|
|
55
61
|
* Offer the starter Agent if this Team never had its chance. Safe to call on
|
|
56
62
|
* every owner directory read: concurrent calls share one attempt, and the
|
package/dist/starter-agent.js
CHANGED
|
@@ -52,11 +52,11 @@ async function settle(host) {
|
|
|
52
52
|
try {
|
|
53
53
|
if (!host.isOwner())
|
|
54
54
|
return "not-owner";
|
|
55
|
-
if (host.ledger.read() !== undefined)
|
|
55
|
+
if ((await host.ledger.read()) !== undefined)
|
|
56
56
|
return "already-offered";
|
|
57
57
|
const at = (host.now ?? Date.now)();
|
|
58
|
-
if (host.agentCount() > 0) {
|
|
59
|
-
host.ledger.record({
|
|
58
|
+
if ((await host.agentCount()) > 0) {
|
|
59
|
+
await host.ledger.record({
|
|
60
60
|
version: starterAgent.version,
|
|
61
61
|
outcome: "team-not-empty",
|
|
62
62
|
agentId: null,
|
|
@@ -70,7 +70,7 @@ async function settle(host) {
|
|
|
70
70
|
});
|
|
71
71
|
if (result.status === "unfunded")
|
|
72
72
|
return "unfunded";
|
|
73
|
-
host.ledger.record({
|
|
73
|
+
await host.ledger.record({
|
|
74
74
|
version: starterAgent.version,
|
|
75
75
|
outcome: "created",
|
|
76
76
|
agentId: result.agentId,
|
package/docs/api/agents.md
CHANGED
|
@@ -199,6 +199,7 @@ type OysterAgents = Readonly<{
|
|
|
199
199
|
)[];
|
|
200
200
|
}>[]
|
|
201
201
|
>;
|
|
202
|
+
ensureStarter: Promise<StarterOutcome>;
|
|
202
203
|
setArchived: Promise<
|
|
203
204
|
| Readonly<{
|
|
204
205
|
archived: boolean;
|
|
@@ -476,6 +477,22 @@ type ModelKeySealInput = Readonly<{
|
|
|
476
477
|
|
|
477
478
|
What the owner submits to seal one provider key.
|
|
478
479
|
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
### StarterOutcome
|
|
483
|
+
|
|
484
|
+
```ts
|
|
485
|
+
type StarterOutcome =
|
|
486
|
+
| "created"
|
|
487
|
+
| "already-offered"
|
|
488
|
+
| "team-not-empty"
|
|
489
|
+
| "unfunded"
|
|
490
|
+
| "not-owner"
|
|
491
|
+
| "failed";
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
How one offer of the starter Agent settled; only `created` made an Agent.
|
|
495
|
+
|
|
479
496
|
## Variables
|
|
480
497
|
|
|
481
498
|
### maxAgentConnections
|
package/docs/api/host.md
CHANGED
package/docs/api/root-data.md
CHANGED
|
@@ -38,6 +38,7 @@ type OysterRootDirectory = Readonly<{
|
|
|
38
38
|
computerId: string;
|
|
39
39
|
name: string;
|
|
40
40
|
}>;
|
|
41
|
+
installing?: readonly InstallingApp[];
|
|
41
42
|
}>;
|
|
42
43
|
```
|
|
43
44
|
|
|
@@ -100,12 +101,12 @@ Data adapters for a standalone workbench over the root's existing owners.
|
|
|
100
101
|
|
|
101
102
|
#### Returns
|
|
102
103
|
|
|
103
|
-
| Name | Type
|
|
104
|
-
| ----------------------------- |
|
|
105
|
-
| `storage` | `object`
|
|
106
|
-
| `storage.purgeInstallation()` | (`address`) => `void`
|
|
107
|
-
| `storage.purgeMember()` | (`memberId`, `throughVersion`) => `void`
|
|
108
|
-
| `openInstallation()` | (`authorize`) => `object`
|
|
109
|
-
| `open()` | (`authorize`) => `object`
|
|
110
|
-
| `directory()` | () => `Promise`\<`Readonly`\<\{ `apps`: readonly `object`[]; `roles`: [`OysterRootRoles`](#oysterrootroles); `computer?`: `Readonly`\<\{ `computerId`: `string`; `name`: `string`; \}\>; \}\>\> | Project the current installations without minting permissions or role choices. |
|
|
111
|
-
| `platformDestinations()` | () => readonly `Readonly`\<\{ `id`: `string`; `label`: `string`; \}\>[]
|
|
104
|
+
| Name | Type | Description |
|
|
105
|
+
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
106
|
+
| `storage` | `object` | Each open(authorize) receives fresh host admission and Release-declared keys. |
|
|
107
|
+
| `storage.purgeInstallation()` | (`address`) => `void` | Remove an installation's values and write counters inside its delete transaction. |
|
|
108
|
+
| `storage.purgeMember()` | (`memberId`, `throughVersion`) => `void` | Remove a member's private values and counters through the revoked membership version. |
|
|
109
|
+
| `openInstallation()` | (`authorize`) => `object` | Bind a lifecycle view to fresh installation admission; only declared team layers are accessible. |
|
|
110
|
+
| `open()` | (`authorize`) => `object` | Bind a member view to live admission, declared keys and the current membership version. |
|
|
111
|
+
| `directory()` | () => `Promise`\<`Readonly`\<\{ `apps`: readonly `object`[]; `roles`: [`OysterRootRoles`](#oysterrootroles); `computer?`: `Readonly`\<\{ `computerId`: `string`; `name`: `string`; \}\>; `installing?`: readonly `object`[]; \}\>\> | Project the current installations without minting permissions or role choices. |
|
|
112
|
+
| `platformDestinations()` | () => readonly `Readonly`\<\{ `id`: `string`; `label`: `string`; \}\>[] | No standalone platform navigation destination is implemented yet. |
|