@fungi.computer/agar 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +766 -2
- package/dist/agent-message-meta.d.ts +74 -0
- package/dist/agent-message-meta.js +63 -0
- package/dist/agents.d.ts +170 -0
- package/dist/agents.js +218 -0
- package/dist/app-build-contract.d.ts +43 -0
- package/dist/app-build-contract.js +24 -0
- package/dist/apps.d.ts +66 -0
- package/dist/apps.js +47 -0
- package/dist/backend-declaration.d.ts +6 -0
- package/dist/backend-declaration.js +65 -0
- package/dist/backend-definition.d.ts +88 -0
- package/dist/backend-definition.js +158 -0
- package/dist/backend-refusal.d.ts +10 -0
- package/dist/backend-refusal.js +10 -0
- package/dist/backend.d.ts +30 -0
- package/dist/backend.js +28 -0
- package/dist/capabilities.d.ts +30 -0
- package/dist/capabilities.js +50 -0
- package/dist/channels.d.ts +142 -0
- package/dist/channels.js +97 -0
- package/dist/commands.d.ts +33 -0
- package/dist/commands.js +46 -0
- package/dist/computer-contracts.d.ts +73 -0
- package/dist/computer-contracts.js +57 -0
- package/dist/computer.d.ts +294 -0
- package/dist/computer.js +319 -0
- package/dist/connect.d.ts +11 -0
- package/dist/connect.js +211 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.js +106 -0
- package/dist/failure.d.ts +2 -0
- package/dist/failure.js +9 -0
- package/dist/files.d.ts +25 -0
- package/dist/files.js +84 -0
- package/dist/game-servers.d.ts +530 -0
- package/dist/game-servers.js +244 -0
- package/dist/gills.d.ts +43 -0
- package/dist/gills.js +174 -0
- package/dist/git-commit.d.ts +143 -0
- package/dist/git-commit.js +251 -0
- package/dist/git-rpc.d.ts +310 -0
- package/dist/git-rpc.js +166 -0
- package/dist/git-steps.d.ts +579 -0
- package/dist/git-steps.js +804 -0
- package/dist/git-wire.d.ts +33 -0
- package/dist/git-wire.js +240 -0
- package/dist/git.d.ts +322 -0
- package/dist/git.js +98 -0
- package/dist/host.d.ts +97 -0
- package/dist/host.js +732 -0
- package/dist/inbox.d.ts +99 -0
- package/dist/inbox.js +184 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +15 -0
- package/dist/inference.d.ts +17 -0
- package/dist/inference.js +115 -0
- package/dist/internal/app-error.d.ts +8 -0
- package/dist/internal/app-error.js +36 -0
- package/dist/internal/app-session.d.ts +8 -0
- package/dist/internal/app-session.js +551 -0
- package/dist/internal/back-inputs.d.ts +22 -0
- package/dist/internal/back-inputs.js +93 -0
- package/dist/internal/browser-bridge.d.ts +30 -0
- package/dist/internal/browser-bridge.js +203 -0
- package/dist/internal/capabilities.d.ts +13 -0
- package/dist/internal/capabilities.js +138 -0
- package/dist/internal/commands.d.ts +9 -0
- package/dist/internal/commands.js +257 -0
- package/dist/internal/disconnect-host.d.ts +7 -0
- package/dist/internal/disconnect-host.js +19 -0
- package/dist/internal/git-edit-tree.d.ts +6 -0
- package/dist/internal/git-edit-tree.js +46 -0
- package/dist/internal/memory-fs.d.ts +39 -0
- package/dist/internal/memory-fs.js +154 -0
- package/dist/internal/protocol.d.ts +116 -0
- package/dist/internal/protocol.js +6 -0
- package/dist/internal/query-feed.d.ts +23 -0
- package/dist/internal/query-feed.js +111 -0
- package/dist/internal/result.d.ts +22 -0
- package/dist/internal/result.js +61 -0
- package/dist/internal/rpc-contract.d.ts +24 -0
- package/dist/internal/rpc-contract.js +78 -0
- package/dist/internal/schemas.d.ts +307 -0
- package/dist/internal/schemas.js +524 -0
- package/dist/internal/store.d.ts +8 -0
- package/dist/internal/store.js +30 -0
- package/dist/internal/terminal-gate.d.ts +17 -0
- package/dist/internal/terminal-gate.js +94 -0
- package/dist/lifecycle.d.ts +44 -0
- package/dist/lifecycle.js +1 -0
- package/dist/marketplace.d.ts +159 -0
- package/dist/marketplace.js +102 -0
- package/dist/media-json.d.ts +181 -0
- package/dist/media-json.js +204 -0
- package/dist/media-library.d.ts +11 -0
- package/dist/media-library.js +15 -0
- package/dist/media-request-id.d.ts +7 -0
- package/dist/media-request-id.js +16 -0
- package/dist/media.d.ts +354 -0
- package/dist/media.js +654 -0
- package/dist/method-refusal.d.ts +64 -0
- package/dist/method-refusal.js +48 -0
- package/dist/pending.d.ts +10 -0
- package/dist/pending.js +10 -0
- package/dist/query.d.ts +76 -0
- package/dist/query.js +195 -0
- package/dist/react-mount.d.ts +23 -0
- package/dist/react-mount.js +108 -0
- package/dist/react.d.ts +41 -0
- package/dist/react.js +111 -0
- package/dist/read-copy.d.ts +103 -0
- package/dist/read-copy.js +195 -0
- package/dist/roles/files.d.ts +295 -0
- package/dist/roles/files.js +184 -0
- package/dist/root.d.ts +21 -0
- package/dist/root.js +1 -0
- package/dist/rpc.d.ts +1 -0
- package/dist/rpc.js +1 -0
- package/dist/status.d.ts +17 -0
- package/dist/status.js +50 -0
- package/dist/storage-wire.d.ts +167 -0
- package/dist/storage-wire.js +115 -0
- package/dist/storage.d.ts +72 -0
- package/dist/storage.js +143 -0
- package/dist/store.d.ts +11 -0
- package/dist/store.js +1 -0
- package/dist/test-kit/git.d.ts +31 -0
- package/dist/test-kit/git.js +174 -0
- package/dist/ui.d.ts +169 -0
- package/dist/ui.js +10 -0
- package/dist/window.d.ts +41 -0
- package/dist/window.js +15 -0
- package/dist/world.d.ts +16 -0
- package/dist/world.js +17 -0
- package/docs/api/README.md +28 -0
- package/docs/api/app-build-contract.md +113 -0
- package/docs/api/backend-declaration.md +62 -0
- package/docs/api/backend-definition.md +215 -0
- package/docs/api/backend.md +269 -0
- package/docs/api/errors.md +169 -0
- package/docs/api/files.md +91 -0
- package/docs/api/gills.md +164 -0
- package/docs/api/git-commit.md +279 -0
- package/docs/api/git-rpc.md +243 -0
- package/docs/api/git-steps.md +1010 -0
- package/docs/api/git-wire.md +197 -0
- package/docs/api/git.md +579 -0
- package/docs/api/index.md +2880 -0
- package/docs/api/media-json.md +507 -0
- package/docs/api/media-request-id.md +32 -0
- package/docs/api/modules.md +32 -0
- package/docs/api/query.md +253 -0
- package/docs/api/react.md +216 -0
- package/docs/api/read-copy.md +204 -0
- package/docs/api/rpc.md +128 -0
- package/docs/api/storage.md +620 -0
- package/package.json +197 -3
package/dist/git.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { gitRepositoryNameSchema, gitSha1Schema, gitRefUpdateSchema, gitPushEventIdSchema, } from "@fungi.computer/puffball/git-representation";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { appMethodCallerSchema, hostActorSchema, workflowAttestationSchema, } from "@fungi.computer/puffball/app-method-runtime";
|
|
4
|
+
/** Requested installation-scoped Git authority; a declaration is never a grant. */
|
|
5
|
+
export const gitRepositoryCapability = "git.repository";
|
|
6
|
+
/**
|
|
7
|
+
* Host-selected repository namespace. Team identity comes from the host;
|
|
8
|
+
* decoding this reference never grants access to either namespace.
|
|
9
|
+
*/
|
|
10
|
+
export const repositoryRefSchema = z.discriminatedUnion("kind", [
|
|
11
|
+
z.strictObject({
|
|
12
|
+
kind: z.literal("installation"),
|
|
13
|
+
installationId: z.string().min(1).max(256),
|
|
14
|
+
repository: gitRepositoryNameSchema,
|
|
15
|
+
}),
|
|
16
|
+
z.strictObject({
|
|
17
|
+
kind: z.literal("team-source"),
|
|
18
|
+
repository: gitRepositoryNameSchema,
|
|
19
|
+
}),
|
|
20
|
+
]);
|
|
21
|
+
/** Stable namespace identity, serialized through the canonical repository decoder. */
|
|
22
|
+
export function repositoryRefKey(repository) {
|
|
23
|
+
return JSON.stringify(repositoryRefSchema.parse(repository));
|
|
24
|
+
}
|
|
25
|
+
/** Compare repository namespace and coordinates independently of allocation or property order. */
|
|
26
|
+
export function repositoryRefsEqual(left, right) {
|
|
27
|
+
return repositoryRefKey(left) === repositoryRefKey(right);
|
|
28
|
+
}
|
|
29
|
+
const hostActor = z.discriminatedUnion("kind", [
|
|
30
|
+
z.strictObject(hostActorSchema.def.options[0].shape),
|
|
31
|
+
z.strictObject(hostActorSchema.def.options[1].shape),
|
|
32
|
+
z.strictObject(hostActorSchema.def.options[2].shape),
|
|
33
|
+
]);
|
|
34
|
+
/** Canonical Git writer decoder; identity is attested by a host, never by an App. */
|
|
35
|
+
export const gitWriterSchema = z.discriminatedUnion("kind", [
|
|
36
|
+
z.strictObject({
|
|
37
|
+
kind: z.literal("actor"),
|
|
38
|
+
actor: hostActor,
|
|
39
|
+
role: appMethodCallerSchema.shape.role,
|
|
40
|
+
workflow: z
|
|
41
|
+
.strictObject({
|
|
42
|
+
...workflowAttestationSchema.shape,
|
|
43
|
+
armedBy: hostActor,
|
|
44
|
+
branches: z
|
|
45
|
+
.array(z.string().startsWith("refs/heads/").max(1024))
|
|
46
|
+
.min(1)
|
|
47
|
+
.max(256),
|
|
48
|
+
})
|
|
49
|
+
.optional(),
|
|
50
|
+
}),
|
|
51
|
+
z.strictObject({
|
|
52
|
+
kind: z.literal("installation"),
|
|
53
|
+
installationId: z.string().min(1).max(256),
|
|
54
|
+
onBehalfOf: hostActor.nullable(),
|
|
55
|
+
}),
|
|
56
|
+
]);
|
|
57
|
+
/** The App's question covers the whole push, under host-held attribution. */
|
|
58
|
+
export const gitPushQuestionSchema = z.strictObject({
|
|
59
|
+
repository: gitRepositoryNameSchema,
|
|
60
|
+
writer: gitWriterSchema.options[0],
|
|
61
|
+
updates: z.array(gitRefUpdateSchema).min(1).max(256),
|
|
62
|
+
});
|
|
63
|
+
/** A whole push verdict; refusal messages are shown by ordinary Git clients. */
|
|
64
|
+
export const gitPushVerdictSchema = z.discriminatedUnion("allowed", [
|
|
65
|
+
z.strictObject({ allowed: z.literal(true) }),
|
|
66
|
+
z.strictObject({
|
|
67
|
+
allowed: z.literal(false),
|
|
68
|
+
refused: z
|
|
69
|
+
.array(z.strictObject({
|
|
70
|
+
ref: z.string().startsWith("refs/").max(1024),
|
|
71
|
+
message: z.string().max(200),
|
|
72
|
+
}))
|
|
73
|
+
.min(1)
|
|
74
|
+
.max(256),
|
|
75
|
+
}),
|
|
76
|
+
]);
|
|
77
|
+
/** One accepted push, with host attribution and no remote or credential. */
|
|
78
|
+
export const appGitPushFactSchema = z.strictObject({
|
|
79
|
+
repository: gitRepositoryNameSchema,
|
|
80
|
+
writer: gitWriterSchema,
|
|
81
|
+
updates: z.array(gitRefUpdateSchema).min(1).max(256),
|
|
82
|
+
unexplained: z
|
|
83
|
+
.array(z.strictObject({
|
|
84
|
+
ref: z.string().startsWith("refs/").max(1024),
|
|
85
|
+
journaled: gitSha1Schema.nullable(),
|
|
86
|
+
}))
|
|
87
|
+
.max(256)
|
|
88
|
+
.optional(),
|
|
89
|
+
// Host event IDs may include a Computer ID as well as its local event ID.
|
|
90
|
+
eventId: gitPushEventIdSchema,
|
|
91
|
+
});
|
|
92
|
+
/** Parse a host-admitted fact and invoke its lifecycle handler, preserving rejection. */
|
|
93
|
+
export async function dispatchAppGitPush(lifecycle, raw) {
|
|
94
|
+
const fact = appGitPushFactSchema.parse(raw);
|
|
95
|
+
if (lifecycle.onGitPush === undefined)
|
|
96
|
+
throw new Error("App Git push handler unavailable");
|
|
97
|
+
await lifecycle.onGitPush(fact);
|
|
98
|
+
}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { AppCommand } from "./commands.js";
|
|
2
|
+
import type { WhistleExecutionOrigin, WhistleJsonValue } from "@fungi.computer/whistle";
|
|
3
|
+
import type { AppContext, AppIdentity, FocusState } from "./lifecycle.js";
|
|
4
|
+
import type { AppNavigationState } from "./window.js";
|
|
5
|
+
import type { AppBrowserAction, AppBrowserActionOutcome, AgentSessionSelection, AppPermissionOutcome, AppPermissionRequest, AppStatusAction, AppStatusItem, FileNavigationInput, ToastInput } from "./ui.js";
|
|
6
|
+
import { AppError } from "./errors.js";
|
|
7
|
+
import { type AppConnectMessage } from "./internal/protocol.js";
|
|
8
|
+
export type AppHost = {
|
|
9
|
+
disconnect(error?: AppError): Promise<void>;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
requestClose(): Promise<boolean>;
|
|
12
|
+
/** Ask the App to go back one step in its own history; `true` when it did. */
|
|
13
|
+
requestBack(): Promise<boolean>;
|
|
14
|
+
/** Deliver the person's use of a status item; `true` when the App acted. */
|
|
15
|
+
activateStatus(action: AppStatusAction): Promise<boolean>;
|
|
16
|
+
updateContext(fact: AppHostFact<AppContext>): Promise<void>;
|
|
17
|
+
reconfigure(value: AppHostReconfiguration): Promise<void>;
|
|
18
|
+
updateLifecycle(fact: AppHostFact<"connected" | "suspended">): Promise<void>;
|
|
19
|
+
updateReservedChords(fact: AppHostFact<readonly AppHostReservedChord[]>): Promise<void>;
|
|
20
|
+
updateTheme(fact: AppHostFact<string>): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export type AppHostReconfiguration = {
|
|
23
|
+
readonly capabilities: AppHostLaunch["capabilities"];
|
|
24
|
+
readonly context: AppHostFact<AppContext>;
|
|
25
|
+
};
|
|
26
|
+
export type AppHostFact<T> = {
|
|
27
|
+
readonly value: T;
|
|
28
|
+
readonly version: number;
|
|
29
|
+
};
|
|
30
|
+
export type AppHostHandlers = {
|
|
31
|
+
/** Open the embedding host's picker, without accepting an App-selected Computer. */
|
|
32
|
+
readonly requestComputerChoice?: () => Promise<void>;
|
|
33
|
+
readonly requestBrowserAction?: (input: AppBrowserAction) => Promise<AppBrowserActionOutcome>;
|
|
34
|
+
readonly invokeReservedChord: (input: {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly repeat: boolean;
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
readonly onDisconnect: () => Promise<void>;
|
|
39
|
+
readonly openNavigation: (input: FileNavigationInput) => Promise<void>;
|
|
40
|
+
readonly openTeamBilling?: () => Promise<void>;
|
|
41
|
+
readonly openDesktopSettings?: () => Promise<void>;
|
|
42
|
+
readonly requestAppPermissions?: (input: AppPermissionRequest) => Promise<AppPermissionOutcome>;
|
|
43
|
+
readonly registerCommands: (input: {
|
|
44
|
+
readonly commands: readonly AppCommand[];
|
|
45
|
+
readonly invoke: (commandId: string, input: {
|
|
46
|
+
readonly arguments?: WhistleJsonValue;
|
|
47
|
+
readonly origin: WhistleExecutionOrigin;
|
|
48
|
+
readonly signal?: AbortSignal;
|
|
49
|
+
}) => Promise<WhistleJsonValue | undefined>;
|
|
50
|
+
}) => Promise<AppCommandContribution>;
|
|
51
|
+
readonly reportFocus: (input: FocusState) => Promise<void>;
|
|
52
|
+
/** The App's latest navigation state; hosts without window chrome omit it. */
|
|
53
|
+
readonly reportNavigation?: (input: AppNavigationState) => Promise<void>;
|
|
54
|
+
/** The App's latest status readouts; hosts without a status bar omit it. */
|
|
55
|
+
readonly reportStatus?: (items: readonly AppStatusItem[]) => Promise<void>;
|
|
56
|
+
readonly reportAgentSessionSelection: (input: AgentSessionSelection | null) => Promise<void>;
|
|
57
|
+
readonly showToast: (input: ToastInput) => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
/** One host-owned Whistle contribution for all commands in an App mount. */
|
|
60
|
+
export type AppCommandContribution = {
|
|
61
|
+
readonly update: (commands: readonly AppCommand[]) => void;
|
|
62
|
+
readonly dispose: () => void;
|
|
63
|
+
};
|
|
64
|
+
export type AppHostLaunch = {
|
|
65
|
+
readonly capabilities: readonly {
|
|
66
|
+
/** A live Cap'n Web handle; it remains opaque to the adapter. */
|
|
67
|
+
readonly handle: object;
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly version: number;
|
|
70
|
+
}[];
|
|
71
|
+
readonly context: AppHostFact<AppContext>;
|
|
72
|
+
readonly identity: AppIdentity;
|
|
73
|
+
readonly lifecycle: AppHostFact<"connected" | "suspended">;
|
|
74
|
+
readonly reservedChords: AppHostFact<readonly AppHostReservedChord[]>;
|
|
75
|
+
readonly theme: AppHostFact<string>;
|
|
76
|
+
};
|
|
77
|
+
export type AppHostReservedChord = {
|
|
78
|
+
readonly altKey: boolean;
|
|
79
|
+
readonly ctrlKey: boolean;
|
|
80
|
+
readonly id: string;
|
|
81
|
+
readonly key: string;
|
|
82
|
+
readonly metaKey: boolean;
|
|
83
|
+
readonly shiftKey: boolean;
|
|
84
|
+
};
|
|
85
|
+
export type ConnectAppHostOptions = {
|
|
86
|
+
readonly appWindow: {
|
|
87
|
+
postMessage(message: AppConnectMessage, targetOrigin: string, transfer: Transferable[]): void;
|
|
88
|
+
};
|
|
89
|
+
/** Serialized document origin; "null" requires a host-owned opaque sandbox. */
|
|
90
|
+
readonly expectedAppOrigin: string;
|
|
91
|
+
readonly handlers: AppHostHandlers;
|
|
92
|
+
readonly hostWindow: Pick<Window, "addEventListener" | "removeEventListener">;
|
|
93
|
+
readonly launch: AppHostLaunch;
|
|
94
|
+
readonly signal?: AbortSignal;
|
|
95
|
+
};
|
|
96
|
+
/** The host-only adapter owns iframe authentication and the hidden Cap'n Web epoch. */
|
|
97
|
+
export declare function connectAppHost(options: ConnectAppHostOptions): Promise<AppHost>;
|