@fungi.computer/computer 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.
Files changed (91) hide show
  1. package/Dockerfile +85 -0
  2. package/LICENSE +21 -0
  3. package/README.md +228 -2
  4. package/container/computer-init.mjs +119 -0
  5. package/container/computer-start.sh +24 -0
  6. package/container/package.json +14 -0
  7. package/container/pnpm-lock.yaml +378 -0
  8. package/container/pnpm-workspace.yaml +5 -0
  9. package/container/resource-bounds.mjs +54 -0
  10. package/container/runtime-privileges.cc +37 -0
  11. package/container/runtime-privileges.mjs +11 -0
  12. package/container/terminal-assets/README.md +35 -0
  13. package/container/terminal-assets/bashrc +49 -0
  14. package/container/terminal-assets/git-prompt.sh +586 -0
  15. package/container/terminal-protocol.mjs +58 -0
  16. package/container/terminal-runtime.mjs +10 -0
  17. package/container/terminal-server.mjs +243 -0
  18. package/dist/apply-patch/LICENSE.codex +201 -0
  19. package/dist/apply-patch/build.mjs +98 -0
  20. package/dist/apply-patch/cache.mjs +168 -0
  21. package/dist/apply-patch/compile.mjs +199 -0
  22. package/dist/apply-patch/docker/darwin.Dockerfile +15 -0
  23. package/dist/apply-patch/docker/linux-arm64.Dockerfile +38 -0
  24. package/dist/apply-patch/docker/linux-x64.Dockerfile +23 -0
  25. package/dist/apply-patch/main.rs +320 -0
  26. package/dist/apply-patch/notices.mjs +44 -0
  27. package/dist/apply-patch/pin.mjs +8 -0
  28. package/dist/apply-patch/toolchain.mjs +39 -0
  29. package/dist/computer-backends.d.ts +94 -0
  30. package/dist/computer-backends.js +103 -0
  31. package/dist/computerd.cjs +18010 -0
  32. package/dist/container-policy.d.ts +7 -0
  33. package/dist/container-policy.js +24 -0
  34. package/dist/container-system-trust.d.ts +8 -0
  35. package/dist/container-system-trust.js +66 -0
  36. package/dist/egress-policy.d.ts +89 -0
  37. package/dist/egress-policy.js +240 -0
  38. package/dist/execution-result.d.ts +3 -0
  39. package/dist/execution-result.js +28 -0
  40. package/dist/files-patch.d.ts +20 -0
  41. package/dist/files-patch.js +108 -0
  42. package/dist/files.d.ts +75 -0
  43. package/dist/files.js +136 -0
  44. package/dist/fleet/admission.d.ts +14 -0
  45. package/dist/fleet/admission.js +10 -0
  46. package/dist/fleet/backing.d.ts +52 -0
  47. package/dist/fleet/backing.js +242 -0
  48. package/dist/fleet/computers.d.ts +62 -0
  49. package/dist/fleet/computers.js +35 -0
  50. package/dist/fleet/index.d.ts +11 -0
  51. package/dist/fleet/index.js +11 -0
  52. package/dist/fleet/inventory-wire.d.ts +29 -0
  53. package/dist/fleet/inventory-wire.js +15 -0
  54. package/dist/fleet/inventory.d.ts +24 -0
  55. package/dist/fleet/inventory.js +152 -0
  56. package/dist/fleet/lifecycle.d.ts +99 -0
  57. package/dist/fleet/lifecycle.js +423 -0
  58. package/dist/fleet/runtime-usage.d.ts +50 -0
  59. package/dist/fleet/runtime-usage.js +145 -0
  60. package/dist/fleet/slots.d.ts +30 -0
  61. package/dist/fleet/slots.js +46 -0
  62. package/dist/fleet/wire.d.ts +228 -0
  63. package/dist/fleet/wire.js +127 -0
  64. package/dist/host-config.d.ts +12 -0
  65. package/dist/host-config.js +10 -0
  66. package/dist/index.d.ts +282 -0
  67. package/dist/index.js +1237 -0
  68. package/dist/light-shell.d.ts +44 -0
  69. package/dist/light-shell.js +376 -0
  70. package/dist/local-backend.d.ts +52 -0
  71. package/dist/local-backend.js +143 -0
  72. package/dist/metered-container-host.d.ts +26 -0
  73. package/dist/metered-container-host.js +48 -0
  74. package/dist/on-box-vm.d.ts +119 -0
  75. package/dist/on-box-vm.js +294 -0
  76. package/dist/operation-contract.d.ts +456 -0
  77. package/dist/operation-contract.js +452 -0
  78. package/dist/operation-record.d.ts +50 -0
  79. package/dist/operation-record.js +162 -0
  80. package/dist/preview.d.ts +55 -0
  81. package/dist/preview.js +151 -0
  82. package/dist/process-inventory.d.ts +80 -0
  83. package/dist/process-inventory.js +427 -0
  84. package/dist/pull-pending.d.ts +26 -0
  85. package/dist/pull-pending.js +35 -0
  86. package/dist/team-candidate-builder.mjs +28170 -0
  87. package/dist/transport-backend.d.ts +3 -0
  88. package/dist/transport-backend.js +99 -0
  89. package/dist/workspace-stream.d.ts +2 -0
  90. package/dist/workspace-stream.js +31 -0
  91. package/package.json +126 -3
@@ -0,0 +1,3 @@
1
+ import type { WorkspaceBackend } from "@fungi.computer/cloudflare-computer";
2
+ /** Adapt remote Computer transport failures to Workspace's existing recovery. */
3
+ export declare function computerTransportBackend(backend: WorkspaceBackend): WorkspaceBackend;
@@ -0,0 +1,99 @@
1
+ import { workspaceStream } from "./workspace-stream.js";
2
+ function transportBoundary(closed) {
3
+ let disconnected = false;
4
+ void closed?.then(() => {
5
+ disconnected = true;
6
+ });
7
+ return async (operation) => {
8
+ try {
9
+ return await operation();
10
+ }
11
+ catch (cause) {
12
+ if (disconnected) {
13
+ // Workspace recognizes a closed WebSocket as a transport failure.
14
+ // Its backend signal, not exception wording, establishes that state.
15
+ throw new Error("WebSocket closed during Computer backend RPC", {
16
+ cause,
17
+ });
18
+ }
19
+ throw cause;
20
+ }
21
+ };
22
+ }
23
+ function transportStream(source, transport) {
24
+ const reader = source.getReader();
25
+ return new ReadableStream({
26
+ async pull(controller) {
27
+ try {
28
+ const next = await transport(() => reader.read());
29
+ if (next.done) {
30
+ reader.releaseLock();
31
+ controller.close();
32
+ }
33
+ else
34
+ controller.enqueue(next.value);
35
+ }
36
+ catch (cause) {
37
+ reader.releaseLock();
38
+ throw cause;
39
+ }
40
+ },
41
+ async cancel(reason) {
42
+ try {
43
+ await reader.cancel(reason);
44
+ }
45
+ finally {
46
+ reader.releaseLock();
47
+ }
48
+ },
49
+ });
50
+ }
51
+ /** Adapt remote Computer transport failures to Workspace's existing recovery. */
52
+ export function computerTransportBackend(backend) {
53
+ const wrapped = {
54
+ id: backend.id,
55
+ type: backend.type,
56
+ async connect(host) {
57
+ const handle = await backend.connect(host);
58
+ const transport = transportBoundary(handle.closed);
59
+ const { sync, shell } = handle.rpc;
60
+ return {
61
+ ...handle,
62
+ close: () => handle.close(),
63
+ rpc: {
64
+ sync: {
65
+ push: (input) => transport(() => sync.push(input)),
66
+ async fetchChanges(input) {
67
+ const result = await transport(() => sync.fetchChanges(input));
68
+ // Preserve the RPC envelope, including its transport disposer.
69
+ result.stream = transportStream(result.stream, transport);
70
+ return result;
71
+ },
72
+ watermarks: () => transport(() => sync.watermarks()),
73
+ readEntry: (path) => transport(() => sync.readEntry(path)),
74
+ hasObjects: (hashes) => transport(() => sync.hasObjects(hashes)),
75
+ fetchObjects: (hashes) => workspaceStream(transport(() => Promise.resolve(sync.fetchObjects(hashes))).then((stream) => transportStream(stream, transport))),
76
+ pushObjects: (objects) => transport(() => sync.pushObjects(objects)),
77
+ },
78
+ shell: {
79
+ async exec(input) {
80
+ const result = await transport(() => shell.exec(input));
81
+ result.events = transportStream(result.events, transport);
82
+ return result;
83
+ },
84
+ async getExec(input) {
85
+ const result = await transport(() => shell.getExec(input));
86
+ result.events = transportStream(result.events, transport);
87
+ return result;
88
+ },
89
+ killExec: (input) => transport(() => shell.killExec(input)),
90
+ disposeExec: (input) => transport(() => shell.disposeExec(input)),
91
+ },
92
+ },
93
+ };
94
+ },
95
+ };
96
+ if (backend.callable === undefined)
97
+ return wrapped;
98
+ return { ...wrapped, callable: backend.callable };
99
+ }
@@ -0,0 +1,2 @@
1
+ /** Give Workspace a stream handle while its remote stream is still resolving. */
2
+ export declare function workspaceStream<T>(remote: PromiseLike<ReadableStream<T>>): ReadableStream<T>;
@@ -0,0 +1,31 @@
1
+ /** Give Workspace a stream handle while its remote stream is still resolving. */
2
+ export function workspaceStream(remote) {
3
+ const reader = Promise.resolve(remote).then((stream) => stream.getReader());
4
+ return new ReadableStream({
5
+ pull: async (controller) => {
6
+ const current = await reader;
7
+ try {
8
+ const next = await current.read();
9
+ if (next.done) {
10
+ current.releaseLock();
11
+ controller.close();
12
+ }
13
+ else
14
+ controller.enqueue(next.value);
15
+ }
16
+ catch (cause) {
17
+ current.releaseLock();
18
+ throw cause;
19
+ }
20
+ },
21
+ cancel: async (reason) => {
22
+ const current = await reader;
23
+ try {
24
+ await current.cancel(reason);
25
+ }
26
+ finally {
27
+ current.releaseLock();
28
+ }
29
+ },
30
+ });
31
+ }
package/package.json CHANGED
@@ -1,6 +1,129 @@
1
1
  {
2
2
  "name": "@fungi.computer/computer",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1",
4
+ "author": "Levi <levi@technomancy.dev>",
5
+ "description": "Cloudflare Computer host for one durable Fungi Computer",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./preview": {
15
+ "types": "./dist/preview.d.ts",
16
+ "import": "./dist/preview.js"
17
+ },
18
+ "./files": {
19
+ "types": "./dist/files.d.ts",
20
+ "import": "./dist/files.js"
21
+ },
22
+ "./backing": {
23
+ "types": "./dist/computer-backends.d.ts",
24
+ "import": "./dist/computer-backends.js"
25
+ },
26
+ "./host-config": {
27
+ "types": "./dist/host-config.d.ts",
28
+ "import": "./dist/host-config.js"
29
+ },
30
+ "./operations": {
31
+ "types": "./dist/operation-contract.d.ts",
32
+ "import": "./dist/operation-contract.js"
33
+ },
34
+ "./container-policy": {
35
+ "types": "./dist/container-policy.d.ts",
36
+ "import": "./dist/container-policy.js"
37
+ },
38
+ "./fleet/wire": {
39
+ "types": "./dist/fleet/wire.d.ts",
40
+ "import": "./dist/fleet/wire.js"
41
+ },
42
+ "./fleet": {
43
+ "types": "./dist/fleet/index.d.ts",
44
+ "import": "./dist/fleet/index.js"
45
+ },
46
+ "./egress": {
47
+ "types": "./dist/egress-policy.d.ts",
48
+ "import": "./dist/egress-policy.js"
49
+ },
50
+ "./light-shell": {
51
+ "types": "./dist/light-shell.d.ts",
52
+ "import": "./dist/light-shell.js"
53
+ }
54
+ },
55
+ "files": [
56
+ "dist",
57
+ "Dockerfile",
58
+ "container",
59
+ "README.md",
60
+ "LICENSE"
61
+ ],
62
+ "dependencies": {
63
+ "@fungi.computer/cairn": "0.0.1",
64
+ "@fungi.computer/cloudflare-computer": "0.2.1-fungi.1",
65
+ "@fungi.computer/cordyceps": "0.2.2",
66
+ "@fungi.computer/knapsack": "0.0.2",
67
+ "@fungi.computer/capnweb": "0.12.0",
68
+ "effect": "4.0.2",
69
+ "zod": "4.4.3",
70
+ "@fungi.computer/seam": "0.0.1",
71
+ "@fungi.computer/watchdog": "0.0.1",
72
+ "just-bash": "3.4.2"
73
+ },
74
+ "devDependencies": {
75
+ "@cloudflare/workers-types": "5.20260828.1",
76
+ "@types/node": "24.13.3",
77
+ "esbuild": "0.28.2",
78
+ "typescript": "5.9.3",
79
+ "uuid": "11.1.1",
80
+ "wrangler": "4.127.1",
81
+ "eslint": "10.9.1",
82
+ "oxlint": "1.78.0",
83
+ "tsx": "4.23.12"
84
+ },
85
+ "botanical": {
86
+ "role": "runtime",
87
+ "operations": {
88
+ "lint": "required",
89
+ "typecheck": "required",
90
+ "build": "required",
91
+ "test": "required",
92
+ "docs": {
93
+ "status": "not-applicable",
94
+ "reason": "Computer runtime owns no generated API documentation surface"
95
+ },
96
+ "pack": {
97
+ "status": "not-applicable",
98
+ "reason": "Computer runtime is bundled into a container image, not independently packed"
99
+ },
100
+ "smoke": {
101
+ "status": "not-applicable",
102
+ "reason": "The real Worker-runtime test exercises the full container composition"
103
+ },
104
+ "stranger": {
105
+ "status": "not-applicable",
106
+ "reason": "Computer runtime is a container image owner, not an installable library consumer fixture"
107
+ }
108
+ }
109
+ },
110
+ "license": "MIT",
111
+ "scripts": {
112
+ "lint": "eslint src test container scripts --max-warnings=0 && oxlint --config ../../oxlint.config.ts --deny-warnings src test container scripts",
113
+ "typecheck": "tsc -p tsconfig.json --noEmit",
114
+ "build": "pnpm run clean && tsc -p tsconfig.build.json && node scripts/copy-daemon.mjs",
115
+ "build:native": "fungi-apply-patch-build --out native/bin",
116
+ "clean": "node --input-type=module --eval \"import { rm } from 'node:fs/promises'; await rm('dist', { recursive: true, force: true });\"",
117
+ "test": "pnpm run test:unit && pnpm run test:fleet-native && node test/port-proof.mjs && node test/terminal-container-proof.mjs && node test/fuse-startup-proof.mjs && node test/container-resource-proof.mjs && node test/runtime-proof.mjs && node test/process-schema-proof.mjs && node test/process-proof.mjs && node test/terminal-proof.mjs && pnpm run test:app-method-execution",
118
+ "format:check": "node ../../tooling/repository/scripts/format-package-check.mjs",
119
+ "lint:anti-slop": "node ../../tooling/repository/scripts/lint-package-anti-slop.mjs",
120
+ "test:merge": "pnpm run test",
121
+ "test:nightly": "bash ../../.agents/skills/orchestrate-multi-lane-work/scripts/run-proof.sh node test/egress-proof.mjs",
122
+ "test:app-method-execution": "node test/app-method-execution-proof.mjs",
123
+ "test:unit": "node --test test/egress-policy.test.mjs test/preview.test.mjs test/light-shell.test.mjs test/fleet.test.mjs test/proof-worker.test.mjs test/workspace-sync.test.mjs test/files-patch.test.mjs && node test/reserved-ports.test.mjs && node --test test/seam-signature.test.mjs test/computer-backends.test.mjs test/terminal-welcome.test.mjs && node test/terminal-protocol.test.mjs && node test/container-policy.test.mjs && node test/files-adapter-proof.mjs && node test/operation-record-proof.mjs && node test/process-inventory-proof.mjs",
124
+ "test:fleet-native": "node test/fleet.native.mjs",
125
+ "test:light-shell": "node --test test/light-shell.test.mjs",
126
+ "test:light-shell:native": "node --import tsx test/light-shell.native.mjs --state",
127
+ "assemble:image": "node scripts/assemble-image.mjs"
128
+ }
6
129
  }