@fungi.computer/truffle 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +542 -2
- package/computerd-loopback.cjs +16 -0
- package/dist/auth-cli.d.ts +46 -0
- package/dist/auth-cli.js +373 -0
- package/dist/fungi-account-command.d.ts +18 -0
- package/dist/fungi-account-command.js +95 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +23 -0
- package/dist/internal/image-fit-metafile.json +106 -0
- package/dist/internal/local-image-fit-worker.mjs +960 -0
- package/dist/internal/private-workerd-sandbox-worker.mjs +27487 -0
- package/dist/internal/sandbox-metafile.json +6726 -0
- package/dist/linear-auth.d.ts +4 -0
- package/dist/linear-auth.js +72 -0
- package/dist/local-archive-handoff.d.ts +12 -0
- package/dist/local-archive-handoff.js +21 -0
- package/dist/local-extensions.d.ts +143 -0
- package/dist/local-extensions.js +624 -0
- package/dist/local-image-fit.d.ts +30 -0
- package/dist/local-image-fit.js +105 -0
- package/dist/local-login.d.ts +55 -0
- package/dist/local-login.js +167 -0
- package/dist/local-models.d.ts +16 -0
- package/dist/local-models.js +82 -0
- package/dist/local-session-archives.d.ts +8 -0
- package/dist/local-session-archives.js +152 -0
- package/dist/local-skill-source.d.ts +21 -0
- package/dist/local-skill-source.js +433 -0
- package/dist/log-event.d.ts +9 -0
- package/dist/log-event.js +13 -0
- package/dist/private-bounded-response.d.ts +2 -0
- package/dist/private-bounded-response.js +41 -0
- package/dist/private-bun-shiitake-host.d.ts +11 -0
- package/dist/private-bun-shiitake-host.js +66 -0
- package/dist/private-file-credential-store.d.ts +58 -0
- package/dist/private-file-credential-store.js +331 -0
- package/dist/private-files-patch.d.ts +4 -0
- package/dist/private-files-patch.js +104 -0
- package/dist/private-fungi-account.d.ts +252 -0
- package/dist/private-fungi-account.js +1329 -0
- package/dist/private-fungi-auth-error.d.ts +5 -0
- package/dist/private-fungi-auth-error.js +7 -0
- package/dist/private-fungi-mcp-connection.d.ts +26 -0
- package/dist/private-fungi-mcp-connection.js +162 -0
- package/dist/private-fungi-mcp-endpoint.d.ts +2 -0
- package/dist/private-fungi-mcp-endpoint.js +15 -0
- package/dist/private-fungi-mcp-selection-schema.d.ts +7 -0
- package/dist/private-fungi-mcp-selection-schema.js +15 -0
- package/dist/private-fungi-mcp-selection.d.ts +14 -0
- package/dist/private-fungi-mcp-selection.js +49 -0
- package/dist/private-fungi-model-api.d.ts +6 -0
- package/dist/private-fungi-model-api.js +125 -0
- package/dist/private-fungi-model-catalog.d.ts +16 -0
- package/dist/private-fungi-model-catalog.js +86 -0
- package/dist/private-fungi-model-provider.d.ts +6 -0
- package/dist/private-fungi-model-provider.js +51 -0
- package/dist/private-fungi-pending-logouts.d.ts +34 -0
- package/dist/private-fungi-pending-logouts.js +135 -0
- package/dist/private-fungi-service-logout.d.ts +44 -0
- package/dist/private-fungi-service-logout.js +59 -0
- package/dist/private-invocation-computer.d.ts +58 -0
- package/dist/private-invocation-computer.js +498 -0
- package/dist/private-invocation-files.d.ts +30 -0
- package/dist/private-invocation-files.js +520 -0
- package/dist/private-local-acp-stdio.d.ts +17 -0
- package/dist/private-local-acp-stdio.js +145 -0
- package/dist/private-local-admission-gate.d.ts +14 -0
- package/dist/private-local-admission-gate.js +52 -0
- package/dist/private-local-agent-control.d.ts +101 -0
- package/dist/private-local-agent-control.js +30 -0
- package/dist/private-local-agent-default-model.d.ts +12 -0
- package/dist/private-local-agent-default-model.js +31 -0
- package/dist/private-local-auth-rpc.d.ts +129 -0
- package/dist/private-local-auth-rpc.js +396 -0
- package/dist/private-local-bwrap.d.ts +13 -0
- package/dist/private-local-bwrap.js +70 -0
- package/dist/private-local-client-version.d.ts +5 -0
- package/dist/private-local-client-version.js +43 -0
- package/dist/private-local-computer-attach.d.ts +49 -0
- package/dist/private-local-computer-attach.js +230 -0
- package/dist/private-local-computer-backend.d.ts +282 -0
- package/dist/private-local-computer-backend.js +402 -0
- package/dist/private-local-computer-processes.d.ts +202 -0
- package/dist/private-local-computer-processes.js +613 -0
- package/dist/private-local-config-root.d.ts +21 -0
- package/dist/private-local-config-root.js +19 -0
- package/dist/private-local-containment.d.ts +51 -0
- package/dist/private-local-containment.js +161 -0
- package/dist/private-local-default-model.d.ts +11 -0
- package/dist/private-local-default-model.js +45 -0
- package/dist/private-local-delegation.d.ts +36 -0
- package/dist/private-local-delegation.js +133 -0
- package/dist/private-local-effective-model.d.ts +27 -0
- package/dist/private-local-effective-model.js +17 -0
- package/dist/private-local-exec-environment.d.ts +16 -0
- package/dist/private-local-exec-environment.js +11 -0
- package/dist/private-local-exec-launch.d.ts +41 -0
- package/dist/private-local-exec-launch.js +51 -0
- package/dist/private-local-exec-path.d.ts +6 -0
- package/dist/private-local-exec-path.js +40 -0
- package/dist/private-local-git-exclude.d.ts +2 -0
- package/dist/private-local-git-exclude.js +33 -0
- package/dist/private-local-http-dispatch.d.ts +5 -0
- package/dist/private-local-http-dispatch.js +14 -0
- package/dist/private-local-linux-sandbox.d.ts +8 -0
- package/dist/private-local-linux-sandbox.js +67 -0
- package/dist/private-local-mail.d.ts +13 -0
- package/dist/private-local-mail.js +77 -0
- package/dist/private-local-mesh-enrollment.d.ts +34 -0
- package/dist/private-local-mesh-enrollment.js +188 -0
- package/dist/private-local-mesh-links.d.ts +21 -0
- package/dist/private-local-mesh-links.js +229 -0
- package/dist/private-local-mesh-record.d.ts +120 -0
- package/dist/private-local-mesh-record.js +55 -0
- package/dist/private-local-process-identity.d.ts +20 -0
- package/dist/private-local-process-identity.js +40 -0
- package/dist/private-local-runtime-host.d.ts +192 -0
- package/dist/private-local-runtime-host.js +1177 -0
- package/dist/private-local-sandbox-policy.d.ts +21 -0
- package/dist/private-local-sandbox-policy.js +121 -0
- package/dist/private-local-sandbox.d.ts +37 -0
- package/dist/private-local-sandbox.js +114 -0
- package/dist/private-local-seatbelt.d.ts +24 -0
- package/dist/private-local-seatbelt.js +68 -0
- package/dist/private-local-service-contract.d.ts +170 -0
- package/dist/private-local-service-contract.js +1 -0
- package/dist/private-local-service-discovery.d.ts +217 -0
- package/dist/private-local-service-discovery.js +322 -0
- package/dist/private-local-service-ids.d.ts +3 -0
- package/dist/private-local-service-ids.js +8 -0
- package/dist/private-local-service-lease.d.ts +16 -0
- package/dist/private-local-service-lease.js +105 -0
- package/dist/private-local-service-listener.d.ts +22 -0
- package/dist/private-local-service-listener.js +407 -0
- package/dist/private-local-service-log.d.ts +128 -0
- package/dist/private-local-service-log.js +321 -0
- package/dist/private-local-service-owner.d.ts +135 -0
- package/dist/private-local-service-owner.js +1369 -0
- package/dist/private-local-service-process.d.ts +1 -0
- package/dist/private-local-service-process.js +8 -0
- package/dist/private-local-service-termination.d.ts +7 -0
- package/dist/private-local-service-termination.js +67 -0
- package/dist/private-local-service.d.ts +46 -0
- package/dist/private-local-service.js +606 -0
- package/dist/private-local-session-discovery.d.ts +66 -0
- package/dist/private-local-session-discovery.js +278 -0
- package/dist/private-local-shiitake-host.d.ts +44 -0
- package/dist/private-local-shiitake-host.js +143 -0
- package/dist/private-local-startup-model.d.ts +51 -0
- package/dist/private-local-startup-model.js +86 -0
- package/dist/private-local-stop-all.d.ts +27 -0
- package/dist/private-local-stop-all.js +26 -0
- package/dist/private-local-ui-attachment.d.ts +19 -0
- package/dist/private-local-ui-attachment.js +71 -0
- package/dist/private-local-worker-server.d.ts +16 -0
- package/dist/private-local-worker-server.js +144 -0
- package/dist/private-mcp-form-contract.d.ts +186 -0
- package/dist/private-mcp-form-contract.js +53 -0
- package/dist/private-mcp-form-elicitation.d.ts +18 -0
- package/dist/private-mcp-form-elicitation.js +97 -0
- package/dist/private-mcp-form-session.d.ts +172 -0
- package/dist/private-mcp-form-session.js +148 -0
- package/dist/private-openai-claims.d.ts +30 -0
- package/dist/private-openai-claims.js +69 -0
- package/dist/private-oyster-mcp-auth.d.ts +13 -0
- package/dist/private-oyster-mcp-auth.js +57 -0
- package/dist/private-provider-rejection.d.ts +15 -0
- package/dist/private-provider-rejection.js +24 -0
- package/dist/private-sqlite-owner.d.ts +39 -0
- package/dist/private-sqlite-owner.js +169 -0
- package/dist/private-team-computers.d.ts +38 -0
- package/dist/private-team-computers.js +110 -0
- package/dist/private-workerd-sandbox.d.ts +3 -0
- package/dist/private-workerd-sandbox.js +347 -0
- package/dist/seatbelt/safe-base.sbpl +79 -0
- package/dist/subscription-activation.d.ts +9 -0
- package/dist/subscription-activation.js +62 -0
- package/dist/subscription-identity.d.ts +23 -0
- package/dist/subscription-identity.js +124 -0
- package/dist/subscription-turn.d.ts +17 -0
- package/dist/subscription-turn.js +143 -0
- package/dist/team-apps.d.ts +24 -0
- package/dist/team-apps.js +128 -0
- package/dist/tracker-git-credential.d.ts +15 -0
- package/dist/tracker-git-credential.js +87 -0
- package/native/bin/LICENSE.bubblewrap +502 -0
- package/native/bin/LICENSE.libcap +112 -0
- package/native/bin/LICENSE.sandbox-runtime +201 -0
- package/native/bin/SOURCE.bubblewrap.tar.xz +0 -0
- package/native/bin/build.json +4037 -0
- package/native/bin/bwrap-build-source/Dockerfile +48 -0
- package/native/bin/bwrap-build-source/README.md +96 -0
- package/native/bin/bwrap-build-source/build.mjs +52 -0
- package/native/bin/bwrap-build-source/linux-arm64.ini +14 -0
- package/native/bin/bwrap-build-source/pin.mjs +21 -0
- package/native/bin/bwrap-build-source/record.mjs +74 -0
- package/native/bin/bwrap-build-source/vendor/LICENSE.sandbox-runtime +201 -0
- package/native/bin/bwrap-build-source/vendor/README.md +23 -0
- package/native/bin/bwrap-build-source/vendor/seccomp-unix-block.c +280 -0
- package/native/bin/bwrap-build.json +44 -0
- package/native/bin/fungi-apply-patch +0 -0
- package/native/bin/fungi-bwrap +0 -0
- package/native/bin/fungi-bwrap.sha256 +1 -0
- package/native/bin/fungi-seccomp.bpf +0 -0
- package/native/bin/fungi-seccomp.bpf.sha256 +1 -0
- package/package.json +161 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { mkdir, open } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { decodeJwt } from "jose";
|
|
4
|
+
import lockfile from "proper-lockfile";
|
|
5
|
+
import writeFileAtomic from "write-file-atomic";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { logEvent } from "./log-event.js";
|
|
8
|
+
const identitySchema = z.strictObject({
|
|
9
|
+
issuer: z.url().max(2048),
|
|
10
|
+
userId: z.string().min(1).max(256),
|
|
11
|
+
loginId: z.string().min(1).max(256),
|
|
12
|
+
});
|
|
13
|
+
const detachSchema = z.strictObject({
|
|
14
|
+
teamId: z.string().min(1).max(256),
|
|
15
|
+
computerId: z.string().min(1).max(256),
|
|
16
|
+
requestId: z.string().min(1).max(256),
|
|
17
|
+
});
|
|
18
|
+
const recordSchema = identitySchema.extend({
|
|
19
|
+
revoke: z.boolean(),
|
|
20
|
+
detaches: z.array(detachSchema).max(16),
|
|
21
|
+
});
|
|
22
|
+
const recordsSchema = z.array(recordSchema).max(128);
|
|
23
|
+
const missingFile = z.object({ code: z.literal("ENOENT") });
|
|
24
|
+
/** Decode only routing metadata. These IDs never authorize a revocation. */
|
|
25
|
+
export function loginIdentity(issuer, access) {
|
|
26
|
+
try {
|
|
27
|
+
const claims = decodeJwt(access);
|
|
28
|
+
return identitySchema.parse({
|
|
29
|
+
issuer,
|
|
30
|
+
userId: claims.sub,
|
|
31
|
+
loginId: claims["https://fungi.computer/oauth/login"],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (cause) {
|
|
35
|
+
logEvent("fungi-account.pending-revoke-identity", cause);
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function matches(left, right) {
|
|
40
|
+
return (left.issuer === right.issuer &&
|
|
41
|
+
left.userId === right.userId &&
|
|
42
|
+
left.loginId === right.loginId);
|
|
43
|
+
}
|
|
44
|
+
/** Durable logout intent, separate from the credential that logout destroys. */
|
|
45
|
+
export function pendingLogouts(credentialPath) {
|
|
46
|
+
const path = `${credentialPath}.pending-logouts.json`;
|
|
47
|
+
async function update(change) {
|
|
48
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
49
|
+
const release = await lockfile.lock(path, {
|
|
50
|
+
realpath: false,
|
|
51
|
+
stale: 30_000,
|
|
52
|
+
update: 10_000,
|
|
53
|
+
retries: { retries: 20, factor: 1.2, minTimeout: 25, maxTimeout: 100 },
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
let records = [];
|
|
57
|
+
try {
|
|
58
|
+
const file = await open(path, "r");
|
|
59
|
+
try {
|
|
60
|
+
if ((await file.stat()).size > 256 * 1024)
|
|
61
|
+
throw new Error("Pending revocations exceed the storage limit");
|
|
62
|
+
records = recordsSchema.parse(JSON.parse(await file.readFile("utf8")));
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await file.close();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (cause) {
|
|
69
|
+
if (!missingFile.safeParse(cause).success)
|
|
70
|
+
throw cause;
|
|
71
|
+
}
|
|
72
|
+
const changed = change(records);
|
|
73
|
+
const serialized = JSON.stringify(recordsSchema.parse(changed.records));
|
|
74
|
+
if (Buffer.byteLength(serialized) > 256 * 1024)
|
|
75
|
+
throw new Error("Pending revocations exceed the storage limit");
|
|
76
|
+
await writeFileAtomic(path, serialized, {
|
|
77
|
+
encoding: "utf8",
|
|
78
|
+
fsync: true,
|
|
79
|
+
mode: 0o600,
|
|
80
|
+
});
|
|
81
|
+
return changed.result;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
await release();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
remember(identity, detaches) {
|
|
89
|
+
return update((records) => {
|
|
90
|
+
const next = [
|
|
91
|
+
...records.filter((record) => !matches(record, identity)),
|
|
92
|
+
recordSchema.parse({ ...identity, revoke: true, detaches }),
|
|
93
|
+
];
|
|
94
|
+
let evicted = false;
|
|
95
|
+
while (next.length > 128 ||
|
|
96
|
+
Buffer.byteLength(JSON.stringify(next)) > 256 * 1024) {
|
|
97
|
+
next.shift();
|
|
98
|
+
evicted = true;
|
|
99
|
+
}
|
|
100
|
+
if (evicted)
|
|
101
|
+
logEvent("fungi-account.pending-logout-evicted", new Error("Oldest logout intent evicted at storage limit"));
|
|
102
|
+
return { records: next, result: undefined };
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
confirmed(identity, detach) {
|
|
106
|
+
return update((records) => ({
|
|
107
|
+
records: records
|
|
108
|
+
.map((record) => {
|
|
109
|
+
if (!matches(record, identity))
|
|
110
|
+
return record;
|
|
111
|
+
return detach === undefined
|
|
112
|
+
? { ...record, revoke: false }
|
|
113
|
+
: {
|
|
114
|
+
...record,
|
|
115
|
+
detaches: record.detaches.filter((item) => item.teamId !== detach.teamId ||
|
|
116
|
+
item.computerId !== detach.computerId ||
|
|
117
|
+
item.requestId !== detach.requestId),
|
|
118
|
+
};
|
|
119
|
+
})
|
|
120
|
+
.filter((record) => record.revoke || record.detaches.length > 0),
|
|
121
|
+
result: undefined,
|
|
122
|
+
}));
|
|
123
|
+
},
|
|
124
|
+
forAccount(identity) {
|
|
125
|
+
return update((records) => {
|
|
126
|
+
const kept = records.filter((record) => record.issuer === identity.issuer &&
|
|
127
|
+
record.userId === identity.userId);
|
|
128
|
+
return {
|
|
129
|
+
records: kept,
|
|
130
|
+
result: kept,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FetchLike } from "@modelcontextprotocol/client";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const fungiAccountLogoutRequestSchema: z.ZodObject<{
|
|
4
|
+
credentialPath: z.ZodString;
|
|
5
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export type FungiAccountLogoutRequest = z.infer<typeof fungiAccountLogoutRequestSchema>;
|
|
8
|
+
export declare const fungiAccountLogoutResultSchema: z.ZodObject<{
|
|
9
|
+
kind: z.ZodEnum<{
|
|
10
|
+
"not-logged-in": "not-logged-in";
|
|
11
|
+
removed: "removed";
|
|
12
|
+
revoked: "revoked";
|
|
13
|
+
}>;
|
|
14
|
+
message: z.ZodString;
|
|
15
|
+
unconfirmedComputers: z.ZodArray<z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
url: z.ZodString;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
/** A logout outcome: never a remote-revocation claim the issuer didn't confirm. */
|
|
21
|
+
export type FungiAccountLogoutResult = Readonly<{
|
|
22
|
+
kind: "not-logged-in" | "removed" | "revoked";
|
|
23
|
+
message: string;
|
|
24
|
+
unconfirmedComputers: readonly Readonly<{
|
|
25
|
+
name: string;
|
|
26
|
+
url: string;
|
|
27
|
+
}>[];
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Route a logout to the running Local account owner. It never starts,
|
|
31
|
+
* upgrades, stops or replaces a service. With no service, the caller's own
|
|
32
|
+
* offline clear runs under the ordinary startup lock, so a service cannot
|
|
33
|
+
* start between proving its absence and the store mutation. A live owner
|
|
34
|
+
* that cannot be reached fails closed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function signOutFungiThroughLocalService(endpoint: string | URL | undefined, options: {
|
|
37
|
+
credentialPath: string;
|
|
38
|
+
directory: string;
|
|
39
|
+
fetch?: FetchLike;
|
|
40
|
+
clearOffline: (endpoint: string | URL | undefined, input: {
|
|
41
|
+
credentialPath: string;
|
|
42
|
+
fetch?: FetchLike;
|
|
43
|
+
}) => Promise<FungiAccountLogoutResult>;
|
|
44
|
+
}): Promise<FungiAccountLogoutResult>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { newWebSocketRpcSession } from "@fungi.computer/capnweb";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { acquireServiceLock, readLiveServiceStatus, readServiceRegistration, serviceDirectory, serviceOwnerIsLive, } from "./private-local-service-discovery.js";
|
|
4
|
+
export const fungiAccountLogoutRequestSchema = z.strictObject({
|
|
5
|
+
credentialPath: z.string().min(1),
|
|
6
|
+
endpoint: z.string().optional(),
|
|
7
|
+
});
|
|
8
|
+
export const fungiAccountLogoutResultSchema = z.strictObject({
|
|
9
|
+
kind: z.enum(["not-logged-in", "removed", "revoked"]),
|
|
10
|
+
message: z.string(),
|
|
11
|
+
unconfirmedComputers: z.array(z.strictObject({ name: z.string(), url: z.string() })),
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Route a logout to the running Local account owner. It never starts,
|
|
15
|
+
* upgrades, stops or replaces a service. With no service, the caller's own
|
|
16
|
+
* offline clear runs under the ordinary startup lock, so a service cannot
|
|
17
|
+
* start between proving its absence and the store mutation. A live owner
|
|
18
|
+
* that cannot be reached fails closed.
|
|
19
|
+
*/
|
|
20
|
+
export async function signOutFungiThroughLocalService(endpoint, options) {
|
|
21
|
+
const { clearOffline, directory: requested, ...input } = options;
|
|
22
|
+
const directory = await serviceDirectory(requested);
|
|
23
|
+
const release = await acquireServiceLock(directory, "startup");
|
|
24
|
+
try {
|
|
25
|
+
const registration = await readServiceRegistration(directory);
|
|
26
|
+
const owned = await serviceOwnerIsLive(directory);
|
|
27
|
+
if (registration?.kind !== "current") {
|
|
28
|
+
if (owned)
|
|
29
|
+
throw new Error("The running Local account owner is unavailable");
|
|
30
|
+
return await clearOffline(endpoint, input);
|
|
31
|
+
}
|
|
32
|
+
const probe = await readLiveServiceStatus(registration.record);
|
|
33
|
+
if (probe.kind !== "running") {
|
|
34
|
+
if (owned || probe.kind === "unavailable")
|
|
35
|
+
throw new Error("The running Local account owner is unavailable");
|
|
36
|
+
return await clearOffline(endpoint, input);
|
|
37
|
+
}
|
|
38
|
+
const service = probe.service;
|
|
39
|
+
const url = new URL(`${service.baseUrl}/service/${service.serviceId}/auth`);
|
|
40
|
+
url.protocol = "ws:";
|
|
41
|
+
const socket = new WebSocket(url);
|
|
42
|
+
const remote = newWebSocketRpcSession(socket);
|
|
43
|
+
try {
|
|
44
|
+
const request = {
|
|
45
|
+
credentialPath: input.credentialPath,
|
|
46
|
+
};
|
|
47
|
+
if (endpoint !== undefined)
|
|
48
|
+
request.endpoint = endpoint.toString();
|
|
49
|
+
return fungiAccountLogoutResultSchema.parse(await remote.signOutFungi(request));
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
remote[Symbol.dispose]();
|
|
53
|
+
socket.close();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
await release();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as ChildProcess from "effect/process/ChildProcess";
|
|
2
|
+
import type { KnapsackComputer } from "@fungi.computer/knapsack";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { type PrivateLocalProcessScope } from "./private-local-computer-processes.js";
|
|
5
|
+
import type { SandboxCommand } from "./private-local-containment.js";
|
|
6
|
+
/** The host admits each launch; undefined is its explicit unavailable fallback. */
|
|
7
|
+
export type LocalSandboxLaunch = (cwd: string, argv: readonly [string, ...string[]]) => SandboxCommand | undefined;
|
|
8
|
+
declare const execOutput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
exitCode: z.ZodNumber;
|
|
10
|
+
stdout: z.ZodString;
|
|
11
|
+
stderr: z.ZodString;
|
|
12
|
+
truncated: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodArray<z.ZodObject<{
|
|
13
|
+
stream: z.ZodEnum<{
|
|
14
|
+
stdout: "stdout";
|
|
15
|
+
stderr: "stderr";
|
|
16
|
+
}>;
|
|
17
|
+
keptBytes: z.ZodNumber;
|
|
18
|
+
totalBytes: z.ZodNumber;
|
|
19
|
+
}, z.core.$strict>>]>;
|
|
20
|
+
status: z.ZodEnum<{
|
|
21
|
+
failed: "failed";
|
|
22
|
+
completed: "completed";
|
|
23
|
+
}>;
|
|
24
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
25
|
+
exitCode: z.ZodNumber;
|
|
26
|
+
stdout: z.ZodString;
|
|
27
|
+
stderr: z.ZodString;
|
|
28
|
+
truncated: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodArray<z.ZodObject<{
|
|
29
|
+
stream: z.ZodEnum<{
|
|
30
|
+
stdout: "stdout";
|
|
31
|
+
stderr: "stderr";
|
|
32
|
+
}>;
|
|
33
|
+
keptBytes: z.ZodNumber;
|
|
34
|
+
totalBytes: z.ZodNumber;
|
|
35
|
+
}, z.core.$strict>>]>;
|
|
36
|
+
status: z.ZodLiteral<"deadline_exceeded">;
|
|
37
|
+
timeoutMs: z.ZodNumber;
|
|
38
|
+
elapsedMs: z.ZodNumber;
|
|
39
|
+
message: z.ZodString;
|
|
40
|
+
}, z.core.$strict>], "status">;
|
|
41
|
+
export type ExecOutput = z.output<typeof execOutput>;
|
|
42
|
+
/** Shared bounded native process owner; callers supply argv/stdin, never shell interpolation. */
|
|
43
|
+
export declare function runPrivateInvocationProcess(processCommand: ChildProcess.Command, signal: AbortSignal, timeoutMs: number | undefined, describe?: Readonly<{
|
|
44
|
+
/** The timeout actually requested, before any clamp; defaults to `timeoutMs`. */
|
|
45
|
+
requestedMs?: number;
|
|
46
|
+
/** The real command text, for the timeout message; omitted when not meaningful (e.g. a native helper). */
|
|
47
|
+
describeCommand?: () => string;
|
|
48
|
+
}>): Promise<ExecOutput>;
|
|
49
|
+
/**
|
|
50
|
+
* Construct one private invocation-root Computer: bounded shell exec, plus the
|
|
51
|
+
* background-process operations of `processes` when the host supplies a scope.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createPrivateInvocationComputer(invocationRoot: string, executionPath?: string, processes?: PrivateLocalProcessScope,
|
|
54
|
+
/** Selected host home; standalone callers capture it before any await. */
|
|
55
|
+
home?: string,
|
|
56
|
+
/** Native Local always supplies its live per-Agent admission callback. */
|
|
57
|
+
sandbox?: LocalSandboxLaunch): Promise<KnapsackComputer>;
|
|
58
|
+
export {};
|