@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.
Files changed (159) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +766 -2
  3. package/dist/agent-message-meta.d.ts +74 -0
  4. package/dist/agent-message-meta.js +63 -0
  5. package/dist/agents.d.ts +170 -0
  6. package/dist/agents.js +218 -0
  7. package/dist/app-build-contract.d.ts +43 -0
  8. package/dist/app-build-contract.js +24 -0
  9. package/dist/apps.d.ts +66 -0
  10. package/dist/apps.js +47 -0
  11. package/dist/backend-declaration.d.ts +6 -0
  12. package/dist/backend-declaration.js +65 -0
  13. package/dist/backend-definition.d.ts +88 -0
  14. package/dist/backend-definition.js +158 -0
  15. package/dist/backend-refusal.d.ts +10 -0
  16. package/dist/backend-refusal.js +10 -0
  17. package/dist/backend.d.ts +30 -0
  18. package/dist/backend.js +28 -0
  19. package/dist/capabilities.d.ts +30 -0
  20. package/dist/capabilities.js +50 -0
  21. package/dist/channels.d.ts +142 -0
  22. package/dist/channels.js +97 -0
  23. package/dist/commands.d.ts +33 -0
  24. package/dist/commands.js +46 -0
  25. package/dist/computer-contracts.d.ts +73 -0
  26. package/dist/computer-contracts.js +57 -0
  27. package/dist/computer.d.ts +294 -0
  28. package/dist/computer.js +319 -0
  29. package/dist/connect.d.ts +11 -0
  30. package/dist/connect.js +211 -0
  31. package/dist/errors.d.ts +34 -0
  32. package/dist/errors.js +106 -0
  33. package/dist/failure.d.ts +2 -0
  34. package/dist/failure.js +9 -0
  35. package/dist/files.d.ts +25 -0
  36. package/dist/files.js +84 -0
  37. package/dist/game-servers.d.ts +530 -0
  38. package/dist/game-servers.js +244 -0
  39. package/dist/gills.d.ts +43 -0
  40. package/dist/gills.js +174 -0
  41. package/dist/git-commit.d.ts +143 -0
  42. package/dist/git-commit.js +251 -0
  43. package/dist/git-rpc.d.ts +310 -0
  44. package/dist/git-rpc.js +166 -0
  45. package/dist/git-steps.d.ts +579 -0
  46. package/dist/git-steps.js +804 -0
  47. package/dist/git-wire.d.ts +33 -0
  48. package/dist/git-wire.js +240 -0
  49. package/dist/git.d.ts +322 -0
  50. package/dist/git.js +98 -0
  51. package/dist/host.d.ts +97 -0
  52. package/dist/host.js +732 -0
  53. package/dist/inbox.d.ts +99 -0
  54. package/dist/inbox.js +184 -0
  55. package/dist/index.d.ts +31 -0
  56. package/dist/index.js +15 -0
  57. package/dist/inference.d.ts +17 -0
  58. package/dist/inference.js +115 -0
  59. package/dist/internal/app-error.d.ts +8 -0
  60. package/dist/internal/app-error.js +36 -0
  61. package/dist/internal/app-session.d.ts +8 -0
  62. package/dist/internal/app-session.js +551 -0
  63. package/dist/internal/back-inputs.d.ts +22 -0
  64. package/dist/internal/back-inputs.js +93 -0
  65. package/dist/internal/browser-bridge.d.ts +30 -0
  66. package/dist/internal/browser-bridge.js +203 -0
  67. package/dist/internal/capabilities.d.ts +13 -0
  68. package/dist/internal/capabilities.js +138 -0
  69. package/dist/internal/commands.d.ts +9 -0
  70. package/dist/internal/commands.js +257 -0
  71. package/dist/internal/disconnect-host.d.ts +7 -0
  72. package/dist/internal/disconnect-host.js +19 -0
  73. package/dist/internal/git-edit-tree.d.ts +6 -0
  74. package/dist/internal/git-edit-tree.js +46 -0
  75. package/dist/internal/memory-fs.d.ts +39 -0
  76. package/dist/internal/memory-fs.js +154 -0
  77. package/dist/internal/protocol.d.ts +116 -0
  78. package/dist/internal/protocol.js +6 -0
  79. package/dist/internal/query-feed.d.ts +23 -0
  80. package/dist/internal/query-feed.js +111 -0
  81. package/dist/internal/result.d.ts +22 -0
  82. package/dist/internal/result.js +61 -0
  83. package/dist/internal/rpc-contract.d.ts +24 -0
  84. package/dist/internal/rpc-contract.js +78 -0
  85. package/dist/internal/schemas.d.ts +307 -0
  86. package/dist/internal/schemas.js +524 -0
  87. package/dist/internal/store.d.ts +8 -0
  88. package/dist/internal/store.js +30 -0
  89. package/dist/internal/terminal-gate.d.ts +17 -0
  90. package/dist/internal/terminal-gate.js +94 -0
  91. package/dist/lifecycle.d.ts +44 -0
  92. package/dist/lifecycle.js +1 -0
  93. package/dist/marketplace.d.ts +159 -0
  94. package/dist/marketplace.js +102 -0
  95. package/dist/media-json.d.ts +181 -0
  96. package/dist/media-json.js +204 -0
  97. package/dist/media-library.d.ts +11 -0
  98. package/dist/media-library.js +15 -0
  99. package/dist/media-request-id.d.ts +7 -0
  100. package/dist/media-request-id.js +16 -0
  101. package/dist/media.d.ts +354 -0
  102. package/dist/media.js +654 -0
  103. package/dist/method-refusal.d.ts +64 -0
  104. package/dist/method-refusal.js +48 -0
  105. package/dist/pending.d.ts +10 -0
  106. package/dist/pending.js +10 -0
  107. package/dist/query.d.ts +76 -0
  108. package/dist/query.js +195 -0
  109. package/dist/react-mount.d.ts +23 -0
  110. package/dist/react-mount.js +108 -0
  111. package/dist/react.d.ts +41 -0
  112. package/dist/react.js +111 -0
  113. package/dist/read-copy.d.ts +103 -0
  114. package/dist/read-copy.js +195 -0
  115. package/dist/roles/files.d.ts +295 -0
  116. package/dist/roles/files.js +184 -0
  117. package/dist/root.d.ts +21 -0
  118. package/dist/root.js +1 -0
  119. package/dist/rpc.d.ts +1 -0
  120. package/dist/rpc.js +1 -0
  121. package/dist/status.d.ts +17 -0
  122. package/dist/status.js +50 -0
  123. package/dist/storage-wire.d.ts +167 -0
  124. package/dist/storage-wire.js +115 -0
  125. package/dist/storage.d.ts +72 -0
  126. package/dist/storage.js +143 -0
  127. package/dist/store.d.ts +11 -0
  128. package/dist/store.js +1 -0
  129. package/dist/test-kit/git.d.ts +31 -0
  130. package/dist/test-kit/git.js +174 -0
  131. package/dist/ui.d.ts +169 -0
  132. package/dist/ui.js +10 -0
  133. package/dist/window.d.ts +41 -0
  134. package/dist/window.js +15 -0
  135. package/dist/world.d.ts +16 -0
  136. package/dist/world.js +17 -0
  137. package/docs/api/README.md +28 -0
  138. package/docs/api/app-build-contract.md +113 -0
  139. package/docs/api/backend-declaration.md +62 -0
  140. package/docs/api/backend-definition.md +215 -0
  141. package/docs/api/backend.md +269 -0
  142. package/docs/api/errors.md +169 -0
  143. package/docs/api/files.md +91 -0
  144. package/docs/api/gills.md +164 -0
  145. package/docs/api/git-commit.md +279 -0
  146. package/docs/api/git-rpc.md +243 -0
  147. package/docs/api/git-steps.md +1010 -0
  148. package/docs/api/git-wire.md +197 -0
  149. package/docs/api/git.md +579 -0
  150. package/docs/api/index.md +2880 -0
  151. package/docs/api/media-json.md +507 -0
  152. package/docs/api/media-request-id.md +32 -0
  153. package/docs/api/modules.md +32 -0
  154. package/docs/api/query.md +253 -0
  155. package/docs/api/react.md +216 -0
  156. package/docs/api/read-copy.md +204 -0
  157. package/docs/api/rpc.md +128 -0
  158. package/docs/api/storage.md +620 -0
  159. package/package.json +197 -3
@@ -0,0 +1,166 @@
1
+ import * as z from "zod";
2
+ import {} from "./git.js";
3
+ import { gitRepositoryNameSchema, gitSha1Schema, } from "@fungi.computer/puffball/git-representation";
4
+ const bytes = z
5
+ .instanceof(Uint8Array)
6
+ .refine((value) => value.byteLength <= 32 * 1024 * 1024);
7
+ const headers = z.record(z.string().max(256), z.string().max(8192));
8
+ const identity = z.strictObject({ name: z.string(), email: z.string() });
9
+ const info = z.strictObject({
10
+ name: gitRepositoryNameSchema,
11
+ defaultBranch: z.string(),
12
+ lastPushAt: z.string().nullable(),
13
+ source: gitRepositoryNameSchema.nullable(),
14
+ });
15
+ const commit = z.strictObject({
16
+ hash: gitSha1Schema,
17
+ treeHash: gitSha1Schema,
18
+ message: z.string(),
19
+ author: identity,
20
+ committer: identity,
21
+ parents: z.array(gitSha1Schema),
22
+ authoredAt: z.number().int(),
23
+ committedAt: z.number().int(),
24
+ });
25
+ const tree = z.strictObject({
26
+ name: z.string(),
27
+ mode: z.string(),
28
+ hash: gitSha1Schema,
29
+ type: z.enum(["blob", "tree", "commit"]),
30
+ });
31
+ const request = z.strictObject({
32
+ service: z.enum(["upload-pack", "receive-pack"]),
33
+ phase: z.enum(["advertise", "exchange"]),
34
+ body: bytes.nullable(),
35
+ headers,
36
+ });
37
+ const response = z.strictObject({
38
+ status: z.number().int().min(100).max(599),
39
+ headers,
40
+ body: bytes,
41
+ });
42
+ const createOptions = z
43
+ .strictObject({
44
+ description: z.string().max(8192).optional(),
45
+ defaultBranch: z.string().min(1).max(1024).optional(),
46
+ })
47
+ .optional();
48
+ const forkOptions = z
49
+ .strictObject({ description: z.string().max(8192).optional() })
50
+ .optional();
51
+ const logOptions = z.strictObject({
52
+ ref: z.string().min(1).max(1024),
53
+ limit: z.number().int().min(1).max(1000).optional(),
54
+ offset: z.number().int().nonnegative().optional(),
55
+ });
56
+ /** The native tuple and result grammar shared by the handle and frame entrypoint. */
57
+ export const nativeGitCodecs = {
58
+ create: {
59
+ args: z.tuple([gitRepositoryNameSchema, createOptions]),
60
+ result: info,
61
+ },
62
+ fork: {
63
+ args: z.tuple([
64
+ gitRepositoryNameSchema,
65
+ gitRepositoryNameSchema,
66
+ forkOptions,
67
+ ]),
68
+ result: info,
69
+ },
70
+ cloneUrl: { args: z.tuple([gitRepositoryNameSchema]), result: z.url() },
71
+ info: { args: z.tuple([gitRepositoryNameSchema]), result: info.nullable() },
72
+ delete: { args: z.tuple([gitRepositoryNameSchema]), result: z.boolean() },
73
+ log: {
74
+ args: z.tuple([gitRepositoryNameSchema, logOptions]),
75
+ result: z.array(commit),
76
+ },
77
+ readCommit: {
78
+ args: z.tuple([gitRepositoryNameSchema, gitSha1Schema]),
79
+ result: commit.nullable(),
80
+ },
81
+ readTree: {
82
+ args: z.tuple([gitRepositoryNameSchema, gitSha1Schema]),
83
+ result: z.array(tree).nullable(),
84
+ },
85
+ readBlob: {
86
+ args: z.tuple([gitRepositoryNameSchema, gitSha1Schema]),
87
+ result: bytes.nullable(),
88
+ },
89
+ refs: {
90
+ args: z.tuple([gitRepositoryNameSchema]),
91
+ result: z.array(z.strictObject({ name: z.string(), hash: gitSha1Schema })),
92
+ },
93
+ exchange: {
94
+ args: z.tuple([gitRepositoryNameSchema, request]),
95
+ result: response,
96
+ },
97
+ };
98
+ /** A frame entrypoint uses the same native argument and result codecs as the handle. */
99
+ function frameMethod(codec, operations) {
100
+ return {
101
+ /** Decode the native positional arguments with the method's tuple codec. */
102
+ decodeArgs: (raw) => codec.args.parse(raw),
103
+ /** Validate the native result, preserving binary values. */
104
+ decodeResult: (raw) => codec.result.parse(raw),
105
+ /** Operations the host must grant for these decoded arguments. */
106
+ requiredOperations: (args) => operations(codec.args.parse(args)),
107
+ };
108
+ }
109
+ /** Native Git preserves tuples and binary values through the shared frame factory. */
110
+ export const nativeGitFrameMethods = {
111
+ create: frameMethod(nativeGitCodecs.create, () => ["create"]),
112
+ fork: frameMethod(nativeGitCodecs.fork, () => ["fork"]),
113
+ cloneUrl: frameMethod(nativeGitCodecs.cloneUrl, () => ["read"]),
114
+ info: frameMethod(nativeGitCodecs.info, () => ["read"]),
115
+ delete: frameMethod(nativeGitCodecs.delete, () => ["write"]),
116
+ log: frameMethod(nativeGitCodecs.log, () => ["read"]),
117
+ readCommit: frameMethod(nativeGitCodecs.readCommit, () => ["read"]),
118
+ readTree: frameMethod(nativeGitCodecs.readTree, () => ["read"]),
119
+ readBlob: frameMethod(nativeGitCodecs.readBlob, () => ["read"]),
120
+ refs: frameMethod(nativeGitCodecs.refs, () => ["read"]),
121
+ exchange: frameMethod(nativeGitCodecs.exchange, ([, input]) => [
122
+ "exchange",
123
+ input.service === "receive-pack" ? "write" : "read",
124
+ ]),
125
+ };
126
+ /** Native method identity is a source-owned refinement, not a transport parser. */
127
+ export const nativeGitMethodNameSchema = z.enum([
128
+ "create",
129
+ "fork",
130
+ "cloneUrl",
131
+ "info",
132
+ "delete",
133
+ "log",
134
+ "readCommit",
135
+ "readTree",
136
+ "readBlob",
137
+ "refs",
138
+ "exchange",
139
+ ]);
140
+ /** Dispatch owned tuples through the retained native handle without a JSON conversion. */
141
+ export async function invokeNativeGit(git, method, raw) {
142
+ switch (nativeGitMethodNameSchema.parse(method)) {
143
+ case "create":
144
+ return await git.create(...nativeGitCodecs.create.args.parse(raw));
145
+ case "fork":
146
+ return await git.fork(...nativeGitCodecs.fork.args.parse(raw));
147
+ case "cloneUrl":
148
+ return await git.cloneUrl(...nativeGitCodecs.cloneUrl.args.parse(raw));
149
+ case "info":
150
+ return await git.info(...nativeGitCodecs.info.args.parse(raw));
151
+ case "delete":
152
+ return await git.delete(...nativeGitCodecs.delete.args.parse(raw));
153
+ case "log":
154
+ return await git.log(...nativeGitCodecs.log.args.parse(raw));
155
+ case "readCommit":
156
+ return await git.readCommit(...nativeGitCodecs.readCommit.args.parse(raw));
157
+ case "readTree":
158
+ return await git.readTree(...nativeGitCodecs.readTree.args.parse(raw));
159
+ case "readBlob":
160
+ return await git.readBlob(...nativeGitCodecs.readBlob.args.parse(raw));
161
+ case "refs":
162
+ return await git.refs(...nativeGitCodecs.refs.args.parse(raw));
163
+ case "exchange":
164
+ return await git.exchange(...nativeGitCodecs.exchange.args.parse(raw));
165
+ }
166
+ }