@fungi.computer/truffle 0.0.0-stage → 0.1.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 (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +294 -2
  3. package/computerd-loopback.cjs +16 -0
  4. package/dist/auth-cli.d.ts +36 -0
  5. package/dist/auth-cli.js +351 -0
  6. package/dist/fungi-account-command.d.ts +18 -0
  7. package/dist/fungi-account-command.js +92 -0
  8. package/dist/index.d.ts +19 -0
  9. package/dist/index.js +17 -0
  10. package/dist/internal/private-workerd-sandbox-worker.mjs +27488 -0
  11. package/dist/internal/sandbox-metafile.json +6726 -0
  12. package/dist/linear-auth.d.ts +4 -0
  13. package/dist/linear-auth.js +72 -0
  14. package/dist/local-extensions.d.ts +97 -0
  15. package/dist/local-extensions.js +484 -0
  16. package/dist/local-login.d.ts +55 -0
  17. package/dist/local-login.js +167 -0
  18. package/dist/local-models.d.ts +14 -0
  19. package/dist/local-models.js +77 -0
  20. package/dist/local-skill-source.d.ts +6 -0
  21. package/dist/local-skill-source.js +357 -0
  22. package/dist/log-event.d.ts +2 -0
  23. package/dist/log-event.js +9 -0
  24. package/dist/private-bun-shiitake-host.d.ts +11 -0
  25. package/dist/private-bun-shiitake-host.js +66 -0
  26. package/dist/private-file-credential-store.d.ts +33 -0
  27. package/dist/private-file-credential-store.js +283 -0
  28. package/dist/private-files-patch.d.ts +3 -0
  29. package/dist/private-files-patch.js +86 -0
  30. package/dist/private-fungi-account.d.ts +235 -0
  31. package/dist/private-fungi-account.js +1149 -0
  32. package/dist/private-fungi-auth-error.d.ts +5 -0
  33. package/dist/private-fungi-auth-error.js +7 -0
  34. package/dist/private-fungi-mcp-connection.d.ts +22 -0
  35. package/dist/private-fungi-mcp-connection.js +143 -0
  36. package/dist/private-fungi-mcp-endpoint.d.ts +2 -0
  37. package/dist/private-fungi-mcp-endpoint.js +15 -0
  38. package/dist/private-fungi-mcp-selection.d.ts +14 -0
  39. package/dist/private-fungi-mcp-selection.js +36 -0
  40. package/dist/private-fungi-model-api.d.ts +6 -0
  41. package/dist/private-fungi-model-api.js +125 -0
  42. package/dist/private-fungi-model-catalog.d.ts +6 -0
  43. package/dist/private-fungi-model-catalog.js +78 -0
  44. package/dist/private-fungi-model-provider.d.ts +6 -0
  45. package/dist/private-fungi-model-provider.js +46 -0
  46. package/dist/private-fungi-pending-logouts.d.ts +34 -0
  47. package/dist/private-fungi-pending-logouts.js +136 -0
  48. package/dist/private-invocation-computer.d.ts +37 -0
  49. package/dist/private-invocation-computer.js +459 -0
  50. package/dist/private-invocation-files.d.ts +15 -0
  51. package/dist/private-invocation-files.js +449 -0
  52. package/dist/private-local-acp-stdio.d.ts +17 -0
  53. package/dist/private-local-acp-stdio.js +142 -0
  54. package/dist/private-local-auth-rpc.d.ts +69 -0
  55. package/dist/private-local-auth-rpc.js +273 -0
  56. package/dist/private-local-computer-attach.d.ts +49 -0
  57. package/dist/private-local-computer-attach.js +216 -0
  58. package/dist/private-local-computer-backend.d.ts +282 -0
  59. package/dist/private-local-computer-backend.js +402 -0
  60. package/dist/private-local-computer-processes.d.ts +199 -0
  61. package/dist/private-local-computer-processes.js +589 -0
  62. package/dist/private-local-default-model.d.ts +11 -0
  63. package/dist/private-local-default-model.js +45 -0
  64. package/dist/private-local-delegation.d.ts +29 -0
  65. package/dist/private-local-delegation.js +78 -0
  66. package/dist/private-local-effective-model.d.ts +19 -0
  67. package/dist/private-local-effective-model.js +14 -0
  68. package/dist/private-local-exec-launch.d.ts +41 -0
  69. package/dist/private-local-exec-launch.js +51 -0
  70. package/dist/private-local-exec-path.d.ts +6 -0
  71. package/dist/private-local-exec-path.js +40 -0
  72. package/dist/private-local-git-exclude.d.ts +2 -0
  73. package/dist/private-local-git-exclude.js +33 -0
  74. package/dist/private-local-http-dispatch.d.ts +5 -0
  75. package/dist/private-local-http-dispatch.js +14 -0
  76. package/dist/private-local-mail.d.ts +11 -0
  77. package/dist/private-local-mail.js +69 -0
  78. package/dist/private-local-model-settings.d.ts +5 -0
  79. package/dist/private-local-model-settings.js +31 -0
  80. package/dist/private-local-runtime-host.d.ts +141 -0
  81. package/dist/private-local-runtime-host.js +988 -0
  82. package/dist/private-local-service-contract.d.ts +90 -0
  83. package/dist/private-local-service-contract.js +1 -0
  84. package/dist/private-local-service-discovery.d.ts +101 -0
  85. package/dist/private-local-service-discovery.js +221 -0
  86. package/dist/private-local-service-ids.d.ts +3 -0
  87. package/dist/private-local-service-ids.js +8 -0
  88. package/dist/private-local-service-listener.d.ts +15 -0
  89. package/dist/private-local-service-listener.js +211 -0
  90. package/dist/private-local-service-owner.d.ts +1567 -0
  91. package/dist/private-local-service-owner.js +371 -0
  92. package/dist/private-local-service-process.d.ts +1 -0
  93. package/dist/private-local-service-process.js +6 -0
  94. package/dist/private-local-service.d.ts +17 -0
  95. package/dist/private-local-service.js +330 -0
  96. package/dist/private-local-session-discovery.d.ts +19 -0
  97. package/dist/private-local-session-discovery.js +157 -0
  98. package/dist/private-local-shiitake-host.d.ts +44 -0
  99. package/dist/private-local-shiitake-host.js +143 -0
  100. package/dist/private-local-subagents.d.ts +27 -0
  101. package/dist/private-local-subagents.js +77 -0
  102. package/dist/private-local-worker-server.d.ts +15 -0
  103. package/dist/private-local-worker-server.js +136 -0
  104. package/dist/private-sqlite-owner.d.ts +7 -0
  105. package/dist/private-sqlite-owner.js +103 -0
  106. package/dist/private-team-computers.d.ts +38 -0
  107. package/dist/private-team-computers.js +101 -0
  108. package/dist/private-workerd-sandbox.d.ts +3 -0
  109. package/dist/private-workerd-sandbox.js +347 -0
  110. package/dist/team-apps.d.ts +24 -0
  111. package/dist/team-apps.js +123 -0
  112. package/dist/tracker-git-credential.d.ts +15 -0
  113. package/dist/tracker-git-credential.js +87 -0
  114. package/native/bin/build.json +4037 -0
  115. package/native/bin/fungi-apply-patch +0 -0
  116. package/package.json +148 -3
@@ -0,0 +1,235 @@
1
+ import { type AuthProvider, type FetchLike, type OAuthClientProvider, type StoredOAuthClientInformation } from "@modelcontextprotocol/client";
2
+ import { z } from "zod";
3
+ import type { Credential, CredentialStore, OAuthAuth } from "@earendil-works/pi-ai";
4
+ /**
5
+ * One folder attached to a Team Computer. The absolute folder path and the
6
+ * device's private key never leave this file; the Hub holds only the public
7
+ * key and the two labels.
8
+ */
9
+ declare const localBackendRecordSchema: z.ZodObject<{
10
+ requestId: z.ZodString;
11
+ teamId: z.ZodString;
12
+ computerId: z.ZodString;
13
+ computerName: z.ZodString;
14
+ rootPath: z.ZodString;
15
+ hostLabel: z.ZodString;
16
+ folderLabel: z.ZodString;
17
+ publicKey: z.ZodBase64;
18
+ privateKey: z.ZodBase64;
19
+ backendId: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strict>;
21
+ export type LocalBackendRecord = z.output<typeof localBackendRecordSchema>;
22
+ declare const teamChoiceSchema: z.ZodObject<{
23
+ teamId: z.ZodString;
24
+ handle: z.ZodString;
25
+ name: z.ZodString;
26
+ }, z.core.$strip>;
27
+ export type FungiAccountTeam = z.output<typeof teamChoiceSchema>;
28
+ export type PrivateFungiAccountOAuthProviderOptions = {
29
+ interactive?: boolean;
30
+ credentialPath?: string;
31
+ issuer?: string;
32
+ /** The Team MCP endpoint named in re-login guidance. */
33
+ endpoint?: URL;
34
+ /** The listening loopback callback for an interactive login. */
35
+ redirectUrl?: string;
36
+ openBrowser?: (url: URL) => void;
37
+ };
38
+ /** Hand a Fungi sign-in page to the platform browser; callers show the URL. */
39
+ export declare function launchPlatformBrowser(url: URL): void;
40
+ /** Persisted OAuth state uses Local's existing owner-only Pi credential file. */
41
+ export declare function privateFungiAccountOAuthProvider(options?: PrivateFungiAccountOAuthProviderOptions): OAuthClientProvider & {
42
+ saveClientInformation(information: StoredOAuthClientInformation): Promise<void>;
43
+ expectedState(): string | undefined;
44
+ authorizationUrl(): URL | undefined;
45
+ };
46
+ export type PrivateFungiAccountLoginOptions = {
47
+ credentialPath?: string;
48
+ /**
49
+ * Asked before a login for another origin replaces the saved login. Without
50
+ * it, a login for another origin fails with the logout command to run.
51
+ */
52
+ confirmReplace?: (savedIssuer: string, nextIssuer: string) => Promise<boolean>;
53
+ /** Choose a current membership when the account has several Teams. */
54
+ chooseTeam?: (teams: readonly FungiAccountTeam[]) => Promise<string>;
55
+ signal?: AbortSignal;
56
+ /** The maintained OAuth fetch seam. */
57
+ fetch?: FetchLike;
58
+ /** Opens the Hub pages; the default launches the platform browser. */
59
+ openBrowser?: (url: URL) => void;
60
+ };
61
+ export type PrivateFungiAccountLogoutResult = Readonly<{
62
+ kind: "not-logged-in" | "removed" | "revoked";
63
+ message: string;
64
+ unconfirmedComputers: readonly Readonly<{
65
+ name: string;
66
+ url: string;
67
+ }>[];
68
+ }>;
69
+ export type FungiAccountStatus = {
70
+ issuer: string;
71
+ accessExpiresAt: Date;
72
+ team?: FungiAccountTeam;
73
+ teamCount?: number;
74
+ };
75
+ /** Non-secret status of the shared Fungi account. */
76
+ export declare function readFungiAccountStatus(options?: {
77
+ credentialPath?: string;
78
+ }): Promise<FungiAccountStatus | undefined>;
79
+ /**
80
+ * Remove the saved Fungi MCP login for the endpoint's origin and ask that
81
+ * issuer to revoke its refresh grant. A login for another origin is kept.
82
+ */
83
+ export declare function signOutFungiAccount(rawEndpoint?: string | URL, options?: {
84
+ credentialPath?: string;
85
+ fetch?: FetchLike;
86
+ }): Promise<PrivateFungiAccountLogoutResult>;
87
+ /**
88
+ * Run one Mycelium control call against the Team MCP endpoint with the saved
89
+ * login, and return the tool's text result. An error result or a transport
90
+ * failure is `undefined`: the caller retries with its persisted request id.
91
+ */
92
+ export declare function callFungiMcpTeamControl(teamEndpoint: URL, code: string, options?: Readonly<{
93
+ credentialPath?: string;
94
+ fetch?: FetchLike;
95
+ signal?: AbortSignal;
96
+ timeoutMs?: number;
97
+ }>): Promise<string | undefined>;
98
+ /** The Team MCP endpoint and Team a control call addresses, validated. */
99
+ export declare function fungiMcpTeamEndpoint(rawEndpoint: string | URL): {
100
+ endpoint: URL;
101
+ teamId: string;
102
+ };
103
+ /** The machine's attached folders, as Local keeps them. */
104
+ export declare function readFungiMcpLocalBackends(options?: Readonly<{
105
+ credentialPath?: string;
106
+ }>): Promise<Readonly<{
107
+ issuer: string | undefined;
108
+ backends: LocalBackendRecord[];
109
+ }>>;
110
+ /** Replace the attached folder records in the owner-only credential file. */
111
+ export declare function writeFungiMcpLocalBackends(update: (current: readonly LocalBackendRecord[]) => LocalBackendRecord[], options?: Readonly<{
112
+ credentialPath?: string;
113
+ }>): Promise<void>;
114
+ /** Complete first-party registration and OAuth authorization in a foreground TUI. */
115
+ export declare function signInFungiAccount(rawEndpoint: string | URL, options?: PrivateFungiAccountLoginOptions): Promise<void>;
116
+ /** Switch only to a fresh membership; failure preserves the prior selected Team. */
117
+ export declare function switchFungiAccountTeam(teamId: string, options?: {
118
+ credentialPath?: string;
119
+ fetch?: FetchLike;
120
+ }): Promise<void>;
121
+ export type FungiAccountTeams = Readonly<{
122
+ teams: readonly FungiAccountTeam[];
123
+ selectedTeamId?: string;
124
+ }>;
125
+ /** Fresh memberships for the saved account, with the Team that pays for models. */
126
+ export declare function readFungiAccountTeams(options?: {
127
+ credentialPath?: string;
128
+ fetch?: FetchLike;
129
+ }): Promise<FungiAccountTeams>;
130
+ declare const teamBalanceSchema: z.ZodObject<{
131
+ teamId: z.ZodString;
132
+ balance: z.ZodObject<{
133
+ amount: z.ZodString;
134
+ currency: z.ZodObject<{
135
+ code: z.ZodLiteral<"USD">;
136
+ base: z.ZodLiteral<10>;
137
+ exponent: z.ZodLiteral<2>;
138
+ }, z.core.$strip>;
139
+ scale: z.ZodLiteral<5>;
140
+ }, z.core.$strip>;
141
+ included: z.ZodNullable<z.ZodObject<{
142
+ granted: z.ZodObject<{
143
+ amount: z.ZodString;
144
+ currency: z.ZodObject<{
145
+ code: z.ZodLiteral<"USD">;
146
+ base: z.ZodLiteral<10>;
147
+ exponent: z.ZodLiteral<2>;
148
+ }, z.core.$strip>;
149
+ scale: z.ZodLiteral<5>;
150
+ }, z.core.$strip>;
151
+ remaining: z.ZodObject<{
152
+ amount: z.ZodString;
153
+ currency: z.ZodObject<{
154
+ code: z.ZodLiteral<"USD">;
155
+ base: z.ZodLiteral<10>;
156
+ exponent: z.ZodLiteral<2>;
157
+ }, z.core.$strip>;
158
+ scale: z.ZodLiteral<5>;
159
+ }, z.core.$strip>;
160
+ expiresAt: z.ZodNumber;
161
+ }, z.core.$strict>>;
162
+ reserved: z.ZodObject<{
163
+ amount: z.ZodString;
164
+ currency: z.ZodObject<{
165
+ code: z.ZodLiteral<"USD">;
166
+ base: z.ZodLiteral<10>;
167
+ exponent: z.ZodLiteral<2>;
168
+ }, z.core.$strip>;
169
+ scale: z.ZodLiteral<5>;
170
+ }, z.core.$strip>;
171
+ available: z.ZodObject<{
172
+ amount: z.ZodString;
173
+ currency: z.ZodObject<{
174
+ code: z.ZodLiteral<"USD">;
175
+ base: z.ZodLiteral<10>;
176
+ exponent: z.ZodLiteral<2>;
177
+ }, z.core.$strip>;
178
+ scale: z.ZodLiteral<5>;
179
+ }, z.core.$strip>;
180
+ }, z.core.$strip>;
181
+ export type FungiTeamCredit = z.output<typeof teamBalanceSchema>;
182
+ /**
183
+ * The selected Team's credit as the Hub billing read reports it. Refusals are
184
+ * typed absences: 404 the person is no longer a member, 403 this sign-in
185
+ * lacks the billing:read grant (signed in before it existed; sign in again),
186
+ * 401 the Hub does not admit this sign-in for billing.
187
+ */
188
+ export type FungiTeamBalance = Readonly<{
189
+ kind: "balance";
190
+ credit: FungiTeamCredit;
191
+ }> | Readonly<{
192
+ kind: "not-available";
193
+ reason: "no-team" | "not-a-member" | "sign-in-again" | "sign-in-not-admitted";
194
+ }>;
195
+ export declare function readFungiTeamBalance(options?: {
196
+ credentialPath?: string;
197
+ fetch?: FetchLike;
198
+ }): Promise<FungiTeamBalance>;
199
+ /**
200
+ * One cross-process credential lock serves MCP and model access, but only
201
+ * when the saved access token actually needs it: a plain read never takes
202
+ * the lock or rewrites the file, so a still-valid credential stays untouched.
203
+ */
204
+ export declare function freshFungiAccess(rawHub: string | URL, options?: {
205
+ credentialPath?: string;
206
+ fetch?: FetchLike;
207
+ signal?: AbortSignal;
208
+ /** Compare inside the lock: another request may already have rotated it. */
209
+ rejectedAccess?: string;
210
+ }): Promise<string>;
211
+ /** Retry an explicitly refused request once; the cloned body is replayable. */
212
+ export declare function fungiAccountFetch(rawHub: string | URL, options?: {
213
+ credentialPath?: string;
214
+ fetch?: FetchLike;
215
+ signal?: AbortSignal;
216
+ }): typeof globalThis.fetch;
217
+ /** The SDK owns exactly one retry; this hook rotates only the refused credential. */
218
+ export declare function fungiMcpAccountAuth(endpoint: URL, options?: {
219
+ credentialPath?: string;
220
+ fetch?: FetchLike;
221
+ signal?: AbortSignal;
222
+ }): AuthProvider;
223
+ /** Selected payer metadata belongs to the shared account, never a model request body. */
224
+ export declare function fungiAccountTeam(credential: Credential): FungiAccountTeam;
225
+ /** Pi uses its own locked modify; this owner supplies the same refresh as MCP. */
226
+ export declare function createFungiAccountOAuth(options?: {
227
+ credentialPath?: string;
228
+ fetch?: FetchLike;
229
+ }): OAuthAuth;
230
+ /** Pi deletion clears Local custody and reports unconfirmed remote revocation. */
231
+ export declare function createFungiAccountCredentialStore(options?: {
232
+ credentialPath?: string;
233
+ fetch?: FetchLike;
234
+ }): CredentialStore;
235
+ export {};