@ai-ecoverse/slicc-agent 3.0.0 → 3.1.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/README.md +9 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +2 -2
- package/dist/main.js +10 -3
- package/dist/main.js.map +2 -2
- package/dist/net.js.map +1 -1
- package/dist/prompt.js +14 -8
- package/dist/prompt.js.map +2 -2
- package/dist/system.js +53 -0
- package/dist/system.js.map +7 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/net.d.ts +1 -0
- package/dist/types/prompt.d.ts +2 -0
- package/dist/types/system.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,15 @@ A conversation without a `cwd` works in `/home`.
|
|
|
65
65
|
- opens the encrypted credential store, the AWS Bedrock provider and the session in OPFS SQLite;
|
|
66
66
|
- installs durable's coding tools and SLICC's system prompt, and serves the agent.
|
|
67
67
|
|
|
68
|
+
The system prompt has a `system` section generated at startup from the running worker (`sliccPrompt(facts)`, `systemSection`). It covers:
|
|
69
|
+
- the slicc-agent version, read from its own `package.json`, and that bash runs on the page's slicc-kernel in the browser;
|
|
70
|
+
- the filesystem layout, with `/os` and `/opt` as the system;
|
|
71
|
+
- the commands on `PATH`, listed by a kernel bash;
|
|
72
|
+
- installing tools with `pnpm add -g`, and that there is no ipk;
|
|
73
|
+
- the active transport, from its traits: the page's fetch, a local proxy, or another relay that fetches without CORS (traits can't tell which);
|
|
74
|
+
- that `localhost` is the sandbox's own loopback;
|
|
75
|
+
- what isn't there yet: node or python3 when not on `PATH`, a browser or CDP tool, and GitHub credentials.
|
|
76
|
+
|
|
68
77
|
```js
|
|
69
78
|
const owner = await startAgent({
|
|
70
79
|
worker: () => new Worker(new URL('@ai-ecoverse/slicc-agent/agent-worker', import.meta.url), { type: 'module' }),
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
startAgent
|
|
23
23
|
} from "./owner.js";
|
|
24
24
|
import { applyPatches, patchServerAccept } from "./patches.js";
|
|
25
|
-
import { SliccPrompt } from "./prompt.js";
|
|
25
|
+
import { SliccPrompt, sliccPrompt } from "./prompt.js";
|
|
26
26
|
import {
|
|
27
27
|
AGENT_SESSION,
|
|
28
28
|
AgentControl,
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
openOpfsSqliteStorage,
|
|
46
46
|
WasmSqliteDatabase
|
|
47
47
|
} from "./sqlite.js";
|
|
48
|
+
import { systemSection } from "./system.js";
|
|
48
49
|
import { PortChannel, withUnrefTimers } from "./wire.js";
|
|
49
50
|
import { kernelPort, serveConnections } from "./worker.js";
|
|
50
51
|
export {
|
|
@@ -87,8 +88,10 @@ export {
|
|
|
87
88
|
patchServerAccept,
|
|
88
89
|
runAgentWorker,
|
|
89
90
|
serveConnections,
|
|
91
|
+
sliccPrompt,
|
|
90
92
|
sliccProviders,
|
|
91
93
|
startAgent,
|
|
94
|
+
systemSection,
|
|
92
95
|
transportFetch,
|
|
93
96
|
withDefaultRegions,
|
|
94
97
|
withUnrefTimers
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export {\n ADOBE,\n ADOBE_PROXY,\n type AdobeConfig,\n type AdobeModelInfo,\n adobeConfig,\n adobeModel,\n adobeProvider,\n adobeUsage,\n type Budget,\n} from './adobe.ts';\nexport { type Agent, type AgentOptions, answerText, openAgent } from './agent.ts';\nexport { type AgentConnection, connectAgent } from './client.ts';\nexport { createAgentControl } from './control.ts';\nexport { CREDENTIALS_DATABASE, EncryptedCredentialStore } from './credentials.ts';\nexport { type AgentHost, hostAgent } from './host.ts';\nexport type {\n KernelClient,\n KernelFs,\n KernelProcess,\n KernelStat,\n SpawnOptions,\n} from './kernel/client.ts';\nexport { HOME, type KernelEnvOptions, kernelEnvironment, SliccKernelEnv } from './kernel/env.ts';\nexport { PortListener } from './listener.ts';\nexport {\n type AgentWorkerOptions,\n type AgentWorkerScope,\n type KernelAttach,\n runAgentWorker,\n} from './main.ts';\nexport { type Transport, type TransportResponse, transportFetch } from './net.ts';\nexport {\n AGENT_LOCK,\n type AgentOwner,\n type AgentWorker,\n type OwnerOptions,\n startAgent,\n} from './owner.ts';\nexport { applyPatches, patchServerAccept } from './patches.ts';\nexport { SliccPrompt } from './prompt.ts';\nexport {\n type AccountState,\n AGENT_SESSION,\n AgentControl,\n AgentSessions,\n AgentSettings,\n type AgentSettingsChange,\n AgentTranscript,\n type BudgetState,\n type ModelChoice,\n type OperationError,\n type PromptResult,\n type SendMode,\n type SendRequest,\n type SendResponse,\n type SettingsState,\n type SignIn,\n} from './services.ts';\nexport {\n BEDROCK,\n createAgentSettings,\n createSliccModels,\n DEFAULT_MODEL,\n DEFAULT_REGIONS,\n sliccProviders,\n withDefaultRegions,\n} from './settings.ts';\nexport {\n AGENT_DIRECTORY,\n type OpfsSqliteOptions,\n openMemorySqliteStorage,\n openOpfsSqliteStorage,\n WasmSqliteDatabase,\n} from './sqlite.ts';\nexport { PortChannel, type PortEndpoint, withUnrefTimers } from './wire.ts';\nexport { kernelPort, serveConnections, type WorkerScope } from './worker.ts';\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAwC,YAAY,iBAAiB;AACrE,SAA+B,oBAAoB;AACnD,SAAS,0BAA0B;AACnC,SAAS,sBAAsB,gCAAgC;AAC/D,SAAyB,iBAAiB;AAQ1C,SAAS,MAA6B,mBAAmB,sBAAsB;AAC/E,SAAS,oBAAoB;AAC7B;AAAA,EAIE;AAAA,OACK;AACP,SAAiD,sBAAsB;AACvE;AAAA,EACE;AAAA,EAIA;AAAA,OACK;AACP,SAAS,cAAc,yBAAyB;AAChD,SAAS,mBAAmB;
|
|
4
|
+
"sourcesContent": ["export {\n ADOBE,\n ADOBE_PROXY,\n type AdobeConfig,\n type AdobeModelInfo,\n adobeConfig,\n adobeModel,\n adobeProvider,\n adobeUsage,\n type Budget,\n} from './adobe.ts';\nexport { type Agent, type AgentOptions, answerText, openAgent } from './agent.ts';\nexport { type AgentConnection, connectAgent } from './client.ts';\nexport { createAgentControl } from './control.ts';\nexport { CREDENTIALS_DATABASE, EncryptedCredentialStore } from './credentials.ts';\nexport { type AgentHost, hostAgent } from './host.ts';\nexport type {\n KernelClient,\n KernelFs,\n KernelProcess,\n KernelStat,\n SpawnOptions,\n} from './kernel/client.ts';\nexport { HOME, type KernelEnvOptions, kernelEnvironment, SliccKernelEnv } from './kernel/env.ts';\nexport { PortListener } from './listener.ts';\nexport {\n type AgentWorkerOptions,\n type AgentWorkerScope,\n type KernelAttach,\n runAgentWorker,\n} from './main.ts';\nexport { type Transport, type TransportResponse, transportFetch } from './net.ts';\nexport {\n AGENT_LOCK,\n type AgentOwner,\n type AgentWorker,\n type OwnerOptions,\n startAgent,\n} from './owner.ts';\nexport { applyPatches, patchServerAccept } from './patches.ts';\nexport { SliccPrompt, sliccPrompt } from './prompt.ts';\nexport {\n type AccountState,\n AGENT_SESSION,\n AgentControl,\n AgentSessions,\n AgentSettings,\n type AgentSettingsChange,\n AgentTranscript,\n type BudgetState,\n type ModelChoice,\n type OperationError,\n type PromptResult,\n type SendMode,\n type SendRequest,\n type SendResponse,\n type SettingsState,\n type SignIn,\n} from './services.ts';\nexport {\n BEDROCK,\n createAgentSettings,\n createSliccModels,\n DEFAULT_MODEL,\n DEFAULT_REGIONS,\n sliccProviders,\n withDefaultRegions,\n} from './settings.ts';\nexport {\n AGENT_DIRECTORY,\n type OpfsSqliteOptions,\n openMemorySqliteStorage,\n openOpfsSqliteStorage,\n WasmSqliteDatabase,\n} from './sqlite.ts';\nexport { type SystemFacts, systemSection } from './system.ts';\nexport { PortChannel, type PortEndpoint, withUnrefTimers } from './wire.ts';\nexport { kernelPort, serveConnections, type WorkerScope } from './worker.ts';\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAwC,YAAY,iBAAiB;AACrE,SAA+B,oBAAoB;AACnD,SAAS,0BAA0B;AACnC,SAAS,sBAAsB,gCAAgC;AAC/D,SAAyB,iBAAiB;AAQ1C,SAAS,MAA6B,mBAAmB,sBAAsB;AAC/E,SAAS,oBAAoB;AAC7B;AAAA,EAIE;AAAA,OACK;AACP,SAAiD,sBAAsB;AACvE;AAAA,EACE;AAAA,EAIA;AAAA,OACK;AACP,SAAS,cAAc,yBAAyB;AAChD,SAAS,aAAa,mBAAmB;AACzC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OAUK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA2B,qBAAqB;AAChD,SAAS,aAAgC,uBAAuB;AAChE,SAAS,YAAY,wBAA0C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/main.js
CHANGED
|
@@ -6,7 +6,7 @@ import { EncryptedCredentialStore } from "./credentials.js";
|
|
|
6
6
|
import { hostAgent } from "./host.js";
|
|
7
7
|
import { kernelEnvironment } from "./kernel/env.js";
|
|
8
8
|
import { transportFetch } from "./net.js";
|
|
9
|
-
import {
|
|
9
|
+
import { sliccPrompt } from "./prompt.js";
|
|
10
10
|
import {
|
|
11
11
|
createAgentSettings,
|
|
12
12
|
createSliccModels,
|
|
@@ -14,17 +14,24 @@ import {
|
|
|
14
14
|
sliccProviders
|
|
15
15
|
} from "./settings.js";
|
|
16
16
|
import { openOpfsSqliteStorage } from "./sqlite.js";
|
|
17
|
+
import { agentVersion, commandsOnPath, transportName } from "./system.js";
|
|
17
18
|
import { kernelPort, serveConnections } from "./worker.js";
|
|
18
19
|
async function start(scope, port, options) {
|
|
19
20
|
const attach = options.attach ?? attachKernel;
|
|
20
21
|
const client = await attach(await port);
|
|
21
|
-
|
|
22
|
+
const native = scope.fetch.bind(scope);
|
|
23
|
+
scope.fetch = transportFetch(client.transport, scope.location.origin, native);
|
|
24
|
+
const facts = {
|
|
25
|
+
version: await agentVersion((url) => native(url)),
|
|
26
|
+
commands: await commandsOnPath(client),
|
|
27
|
+
transport: transportName(client.transport)
|
|
28
|
+
};
|
|
22
29
|
const credentials = await (options.credentials ?? (() => EncryptedCredentialStore.open()))();
|
|
23
30
|
const providers = options.providers ?? sliccProviders();
|
|
24
31
|
const models = createSliccModels(credentials, providers);
|
|
25
32
|
const registry = createRegistry();
|
|
26
33
|
registry.install(CodingTools);
|
|
27
|
-
registry.install(
|
|
34
|
+
registry.install(sliccPrompt(facts));
|
|
28
35
|
const agent = await openAgent({
|
|
29
36
|
models,
|
|
30
37
|
model: options.model ?? DEFAULT_MODEL,
|
package/dist/main.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
|
-
"sourcesContent": ["import { attachKernel } from '@ai-ecoverse/slicc-kernel';\nimport type { CredentialStore, Provider } from '@earendil-works/pi-ai';\nimport { createRegistry, type ModelRef, type Storage } from '@earendil-works/pi-durable';\nimport { CodingTools } from '@earendil-works/pi-durable/tools';\nimport { openAgent } from './agent.ts';\nimport { EncryptedCredentialStore } from './credentials.ts';\nimport { type AgentHost, hostAgent } from './host.ts';\nimport type { KernelClient } from './kernel/client.ts';\nimport { kernelEnvironment } from './kernel/env.ts';\nimport { type Transport, transportFetch } from './net.ts';\nimport {
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAE7B,SAAS,sBAAmD;AAC5D,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,gCAAgC;AACzC,SAAyB,iBAAiB;AAE1C,SAAS,yBAAyB;AAClC,SAAyB,sBAAsB;AAC/C,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,YAAY,wBAA0C;AAiB/D,eAAe,MACb,OACA,MACA,SACoB;AACpB,QAAM,SAAuB,QAAQ,UAAU;AAC/C,QAAM,SAAS,MAAM,OAAO,MAAM,IAAI;AACtC,QAAM,QAAQ,eAAe,OAAO,WAAW,MAAM,SAAS,QAAQ,MAAM,MAAM,
|
|
4
|
+
"sourcesContent": ["import { attachKernel } from '@ai-ecoverse/slicc-kernel';\nimport type { CredentialStore, Provider } from '@earendil-works/pi-ai';\nimport { createRegistry, type ModelRef, type Storage } from '@earendil-works/pi-durable';\nimport { CodingTools } from '@earendil-works/pi-durable/tools';\nimport { openAgent } from './agent.ts';\nimport { EncryptedCredentialStore } from './credentials.ts';\nimport { type AgentHost, hostAgent } from './host.ts';\nimport type { KernelClient } from './kernel/client.ts';\nimport { kernelEnvironment } from './kernel/env.ts';\nimport { type Transport, transportFetch } from './net.ts';\nimport { sliccPrompt } from './prompt.ts';\nimport {\n createAgentSettings,\n createSliccModels,\n DEFAULT_MODEL,\n sliccProviders,\n} from './settings.ts';\nimport { openOpfsSqliteStorage } from './sqlite.ts';\nimport { agentVersion, commandsOnPath, transportName } from './system.ts';\nimport { kernelPort, serveConnections, type WorkerScope } from './worker.ts';\n\nexport interface AgentWorkerScope extends WorkerScope {\n fetch: typeof fetch;\n location: { origin: string };\n}\n\nexport type KernelAttach = (port: MessagePort) => Promise<KernelClient & { transport: Transport }>;\n\nexport interface AgentWorkerOptions {\n model?: ModelRef;\n providers?: Provider[];\n attach?: KernelAttach;\n credentials?: () => Promise<CredentialStore>;\n storage?: () => Promise<Storage>;\n}\n\nasync function start(\n scope: AgentWorkerScope,\n port: Promise<MessagePort>,\n options: AgentWorkerOptions\n): Promise<AgentHost> {\n const attach: KernelAttach = options.attach ?? attachKernel;\n const client = await attach(await port);\n const native = scope.fetch.bind(scope);\n scope.fetch = transportFetch(client.transport, scope.location.origin, native);\n const facts = {\n version: await agentVersion((url) => native(url)),\n commands: await commandsOnPath(client),\n transport: transportName(client.transport),\n };\n const credentials = await (options.credentials ?? (() => EncryptedCredentialStore.open()))();\n const providers = options.providers ?? sliccProviders();\n const models = createSliccModels(credentials, providers);\n const registry = createRegistry();\n registry.install(CodingTools);\n registry.install(sliccPrompt(facts));\n const agent = await openAgent({\n models,\n model: options.model ?? DEFAULT_MODEL,\n storage: await (options.storage ?? (() => openOpfsSqliteStorage()))(),\n registry,\n env: kernelEnvironment(client),\n });\n return hostAgent(agent, { settings: await createAgentSettings(models, credentials, providers) });\n}\n\nexport function runAgentWorker(\n scope: AgentWorkerScope,\n options: AgentWorkerOptions = {}\n): Promise<AgentHost> {\n const host = start(scope, kernelPort(scope), options);\n host.catch(() => undefined);\n serveConnections(scope, host);\n return host;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAE7B,SAAS,sBAAmD;AAC5D,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,gCAAgC;AACzC,SAAyB,iBAAiB;AAE1C,SAAS,yBAAyB;AAClC,SAAyB,sBAAsB;AAC/C,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,cAAc,gBAAgB,qBAAqB;AAC5D,SAAS,YAAY,wBAA0C;AAiB/D,eAAe,MACb,OACA,MACA,SACoB;AACpB,QAAM,SAAuB,QAAQ,UAAU;AAC/C,QAAM,SAAS,MAAM,OAAO,MAAM,IAAI;AACtC,QAAM,SAAS,MAAM,MAAM,KAAK,KAAK;AACrC,QAAM,QAAQ,eAAe,OAAO,WAAW,MAAM,SAAS,QAAQ,MAAM;AAC5E,QAAM,QAAQ;AAAA,IACZ,SAAS,MAAM,aAAa,CAAC,QAAQ,OAAO,GAAG,CAAC;AAAA,IAChD,UAAU,MAAM,eAAe,MAAM;AAAA,IACrC,WAAW,cAAc,OAAO,SAAS;AAAA,EAC3C;AACA,QAAM,cAAc,OAAO,QAAQ,gBAAgB,MAAM,yBAAyB,KAAK,IAAI;AAC3F,QAAM,YAAY,QAAQ,aAAa,eAAe;AACtD,QAAM,SAAS,kBAAkB,aAAa,SAAS;AACvD,QAAM,WAAW,eAAe;AAChC,WAAS,QAAQ,WAAW;AAC5B,WAAS,QAAQ,YAAY,KAAK,CAAC;AACnC,QAAM,QAAQ,MAAM,UAAU;AAAA,IAC5B;AAAA,IACA,OAAO,QAAQ,SAAS;AAAA,IACxB,SAAS,OAAO,QAAQ,YAAY,MAAM,sBAAsB,IAAI;AAAA,IACpE;AAAA,IACA,KAAK,kBAAkB,MAAM;AAAA,EAC/B,CAAC;AACD,SAAO,UAAU,OAAO,EAAE,UAAU,MAAM,oBAAoB,QAAQ,aAAa,SAAS,EAAE,CAAC;AACjG;AAEO,SAAS,eACd,OACA,UAA8B,CAAC,GACX;AACpB,QAAM,OAAO,MAAM,OAAO,WAAW,KAAK,GAAG,OAAO;AACpD,OAAK,MAAM,MAAM,MAAS;AAC1B,mBAAiB,OAAO,IAAI;AAC5B,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/net.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/net.ts"],
|
|
4
|
-
"sourcesContent": ["export interface TransportResponse {\n status: number;\n statusText?: string;\n headers: HeadersInit;\n body: AsyncIterable<Uint8Array>;\n}\n\nexport interface Transport {\n traits?: { crossOrigin?: 'cors' | 'any' };\n fetch(request: {\n url: string;\n method: string;\n headers: [string, string][];\n body?: Uint8Array;\n signal?: AbortSignal;\n }): Promise<TransportResponse>;\n}\n\nconst empty = new Set([101, 103, 204, 205, 304]);\n\nfunction stream(body: AsyncIterable<Uint8Array>): ReadableStream<Uint8Array> {\n const iterator = body[Symbol.asyncIterator]();\n return new ReadableStream({\n async pull(controller) {\n const next = await iterator.next();\n if (next.done) controller.close();\n else controller.enqueue(next.value);\n },\n async cancel() {\n await iterator.return?.();\n },\n });\n}\n\nexport function transportFetch(\n transport: Transport,\n origin: string,\n native: typeof fetch = globalThis.fetch.bind(globalThis)\n): typeof fetch {\n return async (input, init) => {\n const request = new Request(input, init);\n if (new URL(request.url).origin === origin || transport.traits?.crossOrigin === 'cors') {\n return native(request);\n }\n const body = ['GET', 'HEAD'].includes(request.method)\n ? undefined\n : new Uint8Array(await request.arrayBuffer());\n const response = await transport.fetch({\n url: request.url,\n method: request.method,\n headers: [...request.headers],\n ...(body ? { body } : {}),\n signal: request.signal,\n });\n return new Response(empty.has(response.status) ? null : stream(response.body), {\n status: response.status,\n statusText: response.statusText ?? '',\n headers: response.headers,\n });\n };\n}\n"],
|
|
4
|
+
"sourcesContent": ["export interface TransportResponse {\n status: number;\n statusText?: string;\n headers: HeadersInit;\n body: AsyncIterable<Uint8Array>;\n}\n\nexport interface Transport {\n traits?: { crossOrigin?: 'cors' | 'any'; manualRedirects?: boolean };\n fetch(request: {\n url: string;\n method: string;\n headers: [string, string][];\n body?: Uint8Array;\n signal?: AbortSignal;\n }): Promise<TransportResponse>;\n}\n\nconst empty = new Set([101, 103, 204, 205, 304]);\n\nfunction stream(body: AsyncIterable<Uint8Array>): ReadableStream<Uint8Array> {\n const iterator = body[Symbol.asyncIterator]();\n return new ReadableStream({\n async pull(controller) {\n const next = await iterator.next();\n if (next.done) controller.close();\n else controller.enqueue(next.value);\n },\n async cancel() {\n await iterator.return?.();\n },\n });\n}\n\nexport function transportFetch(\n transport: Transport,\n origin: string,\n native: typeof fetch = globalThis.fetch.bind(globalThis)\n): typeof fetch {\n return async (input, init) => {\n const request = new Request(input, init);\n if (new URL(request.url).origin === origin || transport.traits?.crossOrigin === 'cors') {\n return native(request);\n }\n const body = ['GET', 'HEAD'].includes(request.method)\n ? undefined\n : new Uint8Array(await request.arrayBuffer());\n const response = await transport.fetch({\n url: request.url,\n method: request.method,\n headers: [...request.headers],\n ...(body ? { body } : {}),\n signal: request.signal,\n });\n return new Response(empty.has(response.status) ? null : stream(response.body), {\n status: response.status,\n statusText: response.statusText ?? '',\n headers: response.headers,\n });\n };\n}\n"],
|
|
5
5
|
"mappings": "AAkBA,MAAM,QAAQ,oBAAI,IAAI,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG,CAAC;AAE/C,SAAS,OAAO,MAA6D;AAC3E,QAAM,WAAW,KAAK,OAAO,aAAa,EAAE;AAC5C,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,YAAM,OAAO,MAAM,SAAS,KAAK;AACjC,UAAI,KAAK,KAAM,YAAW,MAAM;AAAA,UAC3B,YAAW,QAAQ,KAAK,KAAK;AAAA,IACpC;AAAA,IACA,MAAM,SAAS;AACb,YAAM,SAAS,SAAS;AAAA,IAC1B;AAAA,EACF,CAAC;AACH;AAEO,SAAS,eACd,WACA,QACA,SAAuB,WAAW,MAAM,KAAK,UAAU,GACzC;AACd,SAAO,OAAO,OAAO,SAAS;AAC5B,UAAM,UAAU,IAAI,QAAQ,OAAO,IAAI;AACvC,QAAI,IAAI,IAAI,QAAQ,GAAG,EAAE,WAAW,UAAU,UAAU,QAAQ,gBAAgB,QAAQ;AACtF,aAAO,OAAO,OAAO;AAAA,IACvB;AACA,UAAM,OAAO,CAAC,OAAO,MAAM,EAAE,SAAS,QAAQ,MAAM,IAChD,SACA,IAAI,WAAW,MAAM,QAAQ,YAAY,CAAC;AAC9C,UAAM,WAAW,MAAM,UAAU,MAAM;AAAA,MACrC,KAAK,QAAQ;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,SAAS,CAAC,GAAG,QAAQ,OAAO;AAAA,MAC5B,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,MACvB,QAAQ,QAAQ;AAAA,IAClB,CAAC;AACD,WAAO,IAAI,SAAS,MAAM,IAAI,SAAS,MAAM,IAAI,OAAO,OAAO,SAAS,IAAI,GAAG;AAAA,MAC7E,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS,cAAc;AAAA,MACnC,SAAS,SAAS;AAAA,IACpB,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/prompt.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { defineExtension, section } from "@earendil-works/pi-durable";
|
|
2
|
+
import { systemSection } from "./system.js";
|
|
2
3
|
const PREAMBLE = [
|
|
3
4
|
"You are sliccy, the agent of SLICC. You run in a worker inside the user\u2019s browser tab.",
|
|
4
5
|
"Your tools work on slicc-kernel: bash and coreutils compiled to WebAssembly, on the browser\u2019s private file system.",
|
|
5
6
|
"The user can watch and stop your processes from a terminal next to this chat.",
|
|
6
7
|
"Be brief, do the work with your tools, and say what you changed."
|
|
7
8
|
].join("\n");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
function sliccPrompt(facts) {
|
|
10
|
+
return defineExtension({
|
|
11
|
+
name: "slicc",
|
|
12
|
+
sections: [
|
|
13
|
+
section("preamble", () => PREAMBLE, { tag: false }),
|
|
14
|
+
...facts ? [section("system", () => systemSection(facts))] : [],
|
|
15
|
+
section("cwd", (input) => input.env?.cwd)
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const SliccPrompt = sliccPrompt();
|
|
15
20
|
export {
|
|
16
|
-
SliccPrompt
|
|
21
|
+
SliccPrompt,
|
|
22
|
+
sliccPrompt
|
|
17
23
|
};
|
|
18
24
|
//# sourceMappingURL=prompt.js.map
|
package/dist/prompt.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/prompt.ts"],
|
|
4
|
-
"sourcesContent": ["import { defineExtension, section } from '@earendil-works/pi-durable';\n\nconst PREAMBLE = [\n 'You are sliccy, the agent of SLICC. You run in a worker inside the user\u2019s browser tab.',\n 'Your tools work on slicc-kernel: bash and coreutils compiled to WebAssembly, on the browser\u2019s private file system.',\n 'The user can watch and stop your processes from a terminal next to this chat.',\n 'Be brief, do the work with your tools, and say what you changed.',\n].join('\\n');\n\nexport
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB,eAAe;
|
|
4
|
+
"sourcesContent": ["import { defineExtension, section } from '@earendil-works/pi-durable';\nimport { type SystemFacts, systemSection } from './system.ts';\n\nconst PREAMBLE = [\n 'You are sliccy, the agent of SLICC. You run in a worker inside the user\u2019s browser tab.',\n 'Your tools work on slicc-kernel: bash and coreutils compiled to WebAssembly, on the browser\u2019s private file system.',\n 'The user can watch and stop your processes from a terminal next to this chat.',\n 'Be brief, do the work with your tools, and say what you changed.',\n].join('\\n');\n\nexport function sliccPrompt(facts?: SystemFacts) {\n return defineExtension({\n name: 'slicc',\n sections: [\n section('preamble', () => PREAMBLE, { tag: false }),\n ...(facts ? [section('system', () => systemSection(facts))] : []),\n section('cwd', (input) => input.env?.cwd),\n ],\n });\n}\n\nexport const SliccPrompt = sliccPrompt();\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB,eAAe;AACzC,SAA2B,qBAAqB;AAEhD,MAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAEJ,SAAS,YAAY,OAAqB;AAC/C,SAAO,gBAAgB;AAAA,IACrB,MAAM;AAAA,IACN,UAAU;AAAA,MACR,QAAQ,YAAY,MAAM,UAAU,EAAE,KAAK,MAAM,CAAC;AAAA,MAClD,GAAI,QAAQ,CAAC,QAAQ,UAAU,MAAM,cAAc,KAAK,CAAC,CAAC,IAAI,CAAC;AAAA,MAC/D,QAAQ,OAAO,CAAC,UAAU,MAAM,KAAK,GAAG;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;AAEO,MAAM,cAAc,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/system.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const LIST_PATH = 'IFS=:; for d in $PATH; do [ -d "$d" ] && ls -1 "$d"; done';
|
|
2
|
+
const RUNTIMES = ["node", "python3"];
|
|
3
|
+
async function commandsOnPath(client) {
|
|
4
|
+
const decoder = new TextDecoder();
|
|
5
|
+
let out = "";
|
|
6
|
+
try {
|
|
7
|
+
const process = await client.spawn(["bash", "-c", LIST_PATH], {
|
|
8
|
+
onStdout: (bytes) => {
|
|
9
|
+
out += decoder.decode(bytes, { stream: true });
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
await process.exited;
|
|
13
|
+
} catch {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const names = out.split("\n").map((name) => name.trim());
|
|
17
|
+
return [...new Set(names.filter(Boolean))].sort();
|
|
18
|
+
}
|
|
19
|
+
function transportName(transport) {
|
|
20
|
+
const traits = transport?.traits;
|
|
21
|
+
if (traits?.crossOrigin === "cors") {
|
|
22
|
+
return "the page's own fetch, so only servers that allow CORS answer";
|
|
23
|
+
}
|
|
24
|
+
if (traits?.manualRedirects) return "a local proxy (slicc-node) that fetches without CORS";
|
|
25
|
+
return "a relay that fetches without CORS";
|
|
26
|
+
}
|
|
27
|
+
async function agentVersion(fetcher, url = new URL("../package.json", import.meta.url)) {
|
|
28
|
+
try {
|
|
29
|
+
const response = await fetcher(url);
|
|
30
|
+
const manifest = response.ok ? await response.json() : {};
|
|
31
|
+
return manifest.version ?? "unknown";
|
|
32
|
+
} catch {
|
|
33
|
+
return "unknown";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function systemSection(facts) {
|
|
37
|
+
const missing = RUNTIMES.filter((name) => !facts.commands.includes(name));
|
|
38
|
+
return [
|
|
39
|
+
`You are SLICC's agent in seven: slicc-agent ${facts.version}, installed in /opt/agent. Your bash runs on the page's shared slicc-kernel, a WebAssembly sandbox in the user's browser, not on a server or the user's machine.`,
|
|
40
|
+
"Files: / is the browser's private file system (OPFS). Work in /home and /tmp. /os and /opt are the system; change them only when asked.",
|
|
41
|
+
`Commands on PATH: ${facts.commands.join(" ") || "none found"}.`,
|
|
42
|
+
"Install command-line tools with `pnpm add -g <package>`. There is no ipk.",
|
|
43
|
+
`Network: requests go through ${facts.transport}. localhost and 127.0.0.1 are this sandbox's own loopback, not the user's computer.`,
|
|
44
|
+
`Not here yet: ${[...missing, "a browser or CDP tool", "GitHub credentials"].join(", ")}.`
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
agentVersion,
|
|
49
|
+
commandsOnPath,
|
|
50
|
+
systemSection,
|
|
51
|
+
transportName
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/system.ts"],
|
|
4
|
+
"sourcesContent": ["import type { KernelClient } from './kernel/client.ts';\nimport type { Transport } from './net.ts';\n\nexport interface SystemFacts {\n version: string;\n commands: string[];\n transport: string;\n}\n\nconst LIST_PATH = 'IFS=:; for d in $PATH; do [ -d \"$d\" ] && ls -1 \"$d\"; done';\nconst RUNTIMES = ['node', 'python3'];\n\nexport async function commandsOnPath(client: KernelClient): Promise<string[]> {\n const decoder = new TextDecoder();\n let out = '';\n try {\n const process = await client.spawn(['bash', '-c', LIST_PATH], {\n onStdout: (bytes) => {\n out += decoder.decode(bytes, { stream: true });\n },\n });\n await process.exited;\n } catch {\n return [];\n }\n const names = out.split('\\n').map((name) => name.trim());\n return [...new Set(names.filter(Boolean))].sort();\n}\n\nexport function transportName(transport: Transport | undefined): string {\n const traits = transport?.traits;\n if (traits?.crossOrigin === 'cors') {\n return \"the page's own fetch, so only servers that allow CORS answer\";\n }\n if (traits?.manualRedirects) return 'a local proxy (slicc-node) that fetches without CORS';\n return 'a relay that fetches without CORS';\n}\n\nexport async function agentVersion(\n fetcher: (url: URL) => Promise<Response>,\n url = new URL('../package.json', import.meta.url)\n): Promise<string> {\n try {\n const response = await fetcher(url);\n const manifest = response.ok ? ((await response.json()) as { version?: string }) : {};\n return manifest.version ?? 'unknown';\n } catch {\n return 'unknown';\n }\n}\n\nexport function systemSection(facts: SystemFacts): string {\n const missing = RUNTIMES.filter((name) => !facts.commands.includes(name));\n return [\n `You are SLICC's agent in seven: slicc-agent ${facts.version}, installed in /opt/agent. Your bash runs on the page's shared slicc-kernel, a WebAssembly sandbox in the user's browser, not on a server or the user's machine.`,\n \"Files: / is the browser's private file system (OPFS). Work in /home and /tmp. /os and /opt are the system; change them only when asked.\",\n `Commands on PATH: ${facts.commands.join(' ') || 'none found'}.`,\n 'Install command-line tools with `pnpm add -g <package>`. There is no ipk.',\n `Network: requests go through ${facts.transport}. localhost and 127.0.0.1 are this sandbox's own loopback, not the user's computer.`,\n `Not here yet: ${[...missing, 'a browser or CDP tool', 'GitHub credentials'].join(', ')}.`,\n ].join('\\n');\n}\n"],
|
|
5
|
+
"mappings": "AASA,MAAM,YAAY;AAClB,MAAM,WAAW,CAAC,QAAQ,SAAS;AAEnC,eAAsB,eAAe,QAAyC;AAC5E,QAAM,UAAU,IAAI,YAAY;AAChC,MAAI,MAAM;AACV,MAAI;AACF,UAAM,UAAU,MAAM,OAAO,MAAM,CAAC,QAAQ,MAAM,SAAS,GAAG;AAAA,MAC5D,UAAU,CAAC,UAAU;AACnB,eAAO,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAAA,MAC/C;AAAA,IACF,CAAC;AACD,UAAM,QAAQ;AAAA,EAChB,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACA,QAAM,QAAQ,IAAI,MAAM,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC;AACvD,SAAO,CAAC,GAAG,IAAI,IAAI,MAAM,OAAO,OAAO,CAAC,CAAC,EAAE,KAAK;AAClD;AAEO,SAAS,cAAc,WAA0C;AACtE,QAAM,SAAS,WAAW;AAC1B,MAAI,QAAQ,gBAAgB,QAAQ;AAClC,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,gBAAiB,QAAO;AACpC,SAAO;AACT;AAEA,eAAsB,aACpB,SACA,MAAM,IAAI,IAAI,mBAAmB,YAAY,GAAG,GAC/B;AACjB,MAAI;AACF,UAAM,WAAW,MAAM,QAAQ,GAAG;AAClC,UAAM,WAAW,SAAS,KAAO,MAAM,SAAS,KAAK,IAA8B,CAAC;AACpF,WAAO,SAAS,WAAW;AAAA,EAC7B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,cAAc,OAA4B;AACxD,QAAM,UAAU,SAAS,OAAO,CAAC,SAAS,CAAC,MAAM,SAAS,SAAS,IAAI,CAAC;AACxE,SAAO;AAAA,IACL,+CAA+C,MAAM,OAAO;AAAA,IAC5D;AAAA,IACA,qBAAqB,MAAM,SAAS,KAAK,GAAG,KAAK,YAAY;AAAA,IAC7D;AAAA,IACA,gCAAgC,MAAM,SAAS;AAAA,IAC/C,iBAAiB,CAAC,GAAG,SAAS,yBAAyB,oBAAoB,EAAE,KAAK,IAAI,CAAC;AAAA,EACzF,EAAE,KAAK,IAAI;AACb;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,9 +11,10 @@ export { type AgentWorkerOptions, type AgentWorkerScope, type KernelAttach, runA
|
|
|
11
11
|
export { type Transport, type TransportResponse, transportFetch } from './net.ts';
|
|
12
12
|
export { AGENT_LOCK, type AgentOwner, type AgentWorker, type OwnerOptions, startAgent, } from './owner.ts';
|
|
13
13
|
export { applyPatches, patchServerAccept } from './patches.ts';
|
|
14
|
-
export { SliccPrompt } from './prompt.ts';
|
|
14
|
+
export { SliccPrompt, sliccPrompt } from './prompt.ts';
|
|
15
15
|
export { type AccountState, AGENT_SESSION, AgentControl, AgentSessions, AgentSettings, type AgentSettingsChange, AgentTranscript, type BudgetState, type ModelChoice, type OperationError, type PromptResult, type SendMode, type SendRequest, type SendResponse, type SettingsState, type SignIn, } from './services.ts';
|
|
16
16
|
export { BEDROCK, createAgentSettings, createSliccModels, DEFAULT_MODEL, DEFAULT_REGIONS, sliccProviders, withDefaultRegions, } from './settings.ts';
|
|
17
17
|
export { AGENT_DIRECTORY, type OpfsSqliteOptions, openMemorySqliteStorage, openOpfsSqliteStorage, WasmSqliteDatabase, } from './sqlite.ts';
|
|
18
|
+
export { type SystemFacts, systemSection } from './system.ts';
|
|
18
19
|
export { PortChannel, type PortEndpoint, withUnrefTimers } from './wire.ts';
|
|
19
20
|
export { kernelPort, serveConnections, type WorkerScope } from './worker.ts';
|
package/dist/types/net.d.ts
CHANGED
package/dist/types/prompt.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
+
import { type SystemFacts } from './system.ts';
|
|
2
|
+
export declare function sliccPrompt(facts?: SystemFacts): import("@earendil-works/pi-durable").Extension<import("@earendil-works/pi-durable").ToolRegistration>;
|
|
1
3
|
export declare const SliccPrompt: import("@earendil-works/pi-durable").Extension<import("@earendil-works/pi-durable").ToolRegistration>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KernelClient } from './kernel/client.ts';
|
|
2
|
+
import type { Transport } from './net.ts';
|
|
3
|
+
export interface SystemFacts {
|
|
4
|
+
version: string;
|
|
5
|
+
commands: string[];
|
|
6
|
+
transport: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function commandsOnPath(client: KernelClient): Promise<string[]>;
|
|
9
|
+
export declare function transportName(transport: Transport | undefined): string;
|
|
10
|
+
export declare function agentVersion(fetcher: (url: URL) => Promise<Response>, url?: URL): Promise<string>;
|
|
11
|
+
export declare function systemSection(facts: SystemFacts): string;
|
package/package.json
CHANGED