@sixb/cli-core 0.1.9 → 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/README.md +21 -16
- package/dist/api-client.d.ts +1 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/bin/sixb +26 -0
- package/dist/commands/data.d.ts +5 -0
- package/dist/commands/data.d.ts.map +1 -0
- package/dist/commands/files.d.ts.map +1 -1
- package/dist/commands/history.d.ts +7 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/metadata.d.ts +11 -4
- package/dist/commands/metadata.d.ts.map +1 -1
- package/dist/commands/runs.d.ts +8 -1
- package/dist/commands/runs.d.ts.map +1 -1
- package/dist/commands/shared.d.ts +2 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/system.d.ts +21 -0
- package/dist/commands/system.d.ts.map +1 -0
- package/dist/commands/users.d.ts.map +1 -1
- package/dist/generated/sixb.mjs +2658 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +298 -58
- package/dist/index.js.map +21 -17
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/memory.d.ts +21 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/policies.d.ts +14 -0
- package/dist/policies.d.ts.map +1 -1
- package/dist/run.d.ts +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/sandbox-cli.d.ts +8 -0
- package/dist/sandbox-cli.d.ts.map +1 -0
- package/package.json +15 -1
- package/src/api-client.ts +70 -2
- package/src/bin/sixb +26 -0
- package/src/commands/actions.ts +3 -3
- package/src/commands/data.ts +90 -0
- package/src/commands/files.ts +27 -3
- package/src/commands/history.ts +204 -0
- package/src/commands/index.ts +16 -0
- package/src/commands/memory.ts +358 -0
- package/src/commands/metadata.ts +76 -29
- package/src/commands/models.ts +3 -3
- package/src/commands/ontology.ts +2 -2
- package/src/commands/runs.ts +22 -16
- package/src/commands/shared.ts +6 -0
- package/src/commands/system.ts +67 -0
- package/src/commands/telemetry.ts +2 -2
- package/src/commands/users.ts +22 -2
- package/src/commands/workflows.ts +3 -3
- package/src/generated/sixb.mjs +2658 -0
- package/src/index.ts +12 -3
- package/src/main.ts +41 -0
- package/src/memory.ts +30 -0
- package/src/policies.ts +5 -0
- package/src/run.ts +3 -2
- package/src/sandbox-cli.ts +18 -0
package/src/index.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
export type { ApiClientOptions } from "./api-client"
|
|
2
2
|
export { ApiClient } from "./api-client"
|
|
3
|
-
export {
|
|
3
|
+
export { requestsHelp } from "./arguments"
|
|
4
4
|
export type { InstanceCommand } from "./commands"
|
|
5
5
|
export { INSTANCE_COMMANDS, isInstanceCommand } from "./commands"
|
|
6
6
|
export { renderInstanceHelp } from "./commands/metadata"
|
|
7
|
-
export {
|
|
7
|
+
export type { SandboxStatusReport } from "./commands/system"
|
|
8
|
+
export { AGENT_RUNTIME_PROFILE } from "./commands/system"
|
|
9
|
+
export type { AgentMemoryManifest, AgentMemoryRepo } from "./memory"
|
|
10
|
+
export {
|
|
11
|
+
AGENT_MEMORY_ENTRY,
|
|
12
|
+
AGENT_MEMORY_MANIFEST,
|
|
13
|
+
AGENT_MEMORY_STARTER,
|
|
14
|
+
agentMemoryFileHash,
|
|
15
|
+
} from "./memory"
|
|
8
16
|
export {
|
|
9
17
|
CliError,
|
|
10
18
|
EXIT_API,
|
|
@@ -13,7 +21,6 @@ export {
|
|
|
13
21
|
INSTANCE_CLI_VERSION,
|
|
14
22
|
reportError,
|
|
15
23
|
writeJson,
|
|
16
|
-
writeText,
|
|
17
24
|
} from "./output"
|
|
18
25
|
export type {
|
|
19
26
|
InstanceCliMode,
|
|
@@ -22,3 +29,5 @@ export type {
|
|
|
22
29
|
SandboxInstanceCliMode,
|
|
23
30
|
} from "./run"
|
|
24
31
|
export { createInstanceApiClient, runInstanceCli } from "./run"
|
|
32
|
+
export type { SandboxCliAssets } from "./sandbox-cli"
|
|
33
|
+
export { loadSandboxCliAssets } from "./sandbox-cli"
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// The `sixb` a sandbox runs: the API commands people run, plus the run's own (`status`,
|
|
4
|
+
// `context`, `memory`, `history`). `bun run generate:sandbox-cli` bundles it into generated/sixb.mjs.
|
|
5
|
+
import { isHelp } from "./arguments"
|
|
6
|
+
import { isInstanceCommand } from "./commands"
|
|
7
|
+
import { history } from "./commands/history"
|
|
8
|
+
import { memory } from "./commands/memory"
|
|
9
|
+
import { renderInstanceHelp } from "./commands/metadata"
|
|
10
|
+
import { context, status } from "./commands/system"
|
|
11
|
+
import { fail, INSTANCE_CLI_VERSION, reportError, writeText } from "./output"
|
|
12
|
+
import { createInstanceApiClient, runInstanceCli } from "./run"
|
|
13
|
+
|
|
14
|
+
async function main(args: readonly string[]): Promise<void> {
|
|
15
|
+
const [command, ...rest] = args
|
|
16
|
+
if (!command || isHelp(command)) return writeText(renderInstanceHelp())
|
|
17
|
+
if (command === "--version" || command === "version") {
|
|
18
|
+
return writeText(`sixb CLI ${INSTANCE_CLI_VERSION}`)
|
|
19
|
+
}
|
|
20
|
+
if (command === "status") return status(rest, sandboxMode())
|
|
21
|
+
if (command === "context") return context(rest)
|
|
22
|
+
if (command === "memory") return memory(rest, sandboxMode())
|
|
23
|
+
if (command === "history") return history(createInstanceApiClient(sandboxMode()), rest)
|
|
24
|
+
if (!isInstanceCommand(command)) fail(`Unknown command '${command}'. Run 'sixb --help'.`)
|
|
25
|
+
|
|
26
|
+
await runInstanceCli({ args, mode: sandboxMode() })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function sandboxMode() {
|
|
30
|
+
return {
|
|
31
|
+
kind: "sandbox" as const,
|
|
32
|
+
baseUrl: process.env.SIXB_API_BASE_URL ?? "",
|
|
33
|
+
runContextPath: process.env.SIXB_RUN_CONTEXT ?? "",
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
await main(process.argv.slice(2))
|
|
39
|
+
} catch (error) {
|
|
40
|
+
process.exitCode = reportError(error)
|
|
41
|
+
}
|
package/src/memory.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The Agent's memory as installed in its sandbox: the worker writes each repo under
|
|
5
|
+
* `$SIXB_MEMORY_DIR/<repo>/` with a manifest of what it loaded, and `sixb memory` saves the files
|
|
6
|
+
* that differ from it.
|
|
7
|
+
*/
|
|
8
|
+
export type AgentMemoryRepo = "user" | "project"
|
|
9
|
+
|
|
10
|
+
/** Where the manifest is, relative to `$SIXB_CONTEXT_DIR`. */
|
|
11
|
+
export const AGENT_MEMORY_MANIFEST = "context/memory.json"
|
|
12
|
+
|
|
13
|
+
export const AGENT_MEMORY_ENTRY = "MEMORY.md"
|
|
14
|
+
|
|
15
|
+
/** What a repo starts from before its first save; it is saved with the first save. */
|
|
16
|
+
export const AGENT_MEMORY_STARTER = "# Memory\n\n"
|
|
17
|
+
|
|
18
|
+
/** What the local copy was loaded from: the revision and each file's SHA-256, by path. */
|
|
19
|
+
export interface AgentMemoryManifest {
|
|
20
|
+
readonly repos: Partial<Record<AgentMemoryRepo, AgentMemoryManifestRepo>>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AgentMemoryManifestRepo {
|
|
24
|
+
readonly revision: number
|
|
25
|
+
readonly files: Readonly<Record<string, string>>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function agentMemoryFileHash(contents: string): string {
|
|
29
|
+
return createHash("sha256").update(contents).digest("hex")
|
|
30
|
+
}
|
package/src/policies.ts
CHANGED
|
@@ -8,6 +8,11 @@ export const CLI_LIMITS = {
|
|
|
8
8
|
linkPage: { default: 100, maximum: 1_000 },
|
|
9
9
|
/** The server lists at most 200 members per page. */
|
|
10
10
|
users: { default: 20, maximum: 200 },
|
|
11
|
+
/** A page of a conversation's messages, as `sixb history` prints them. */
|
|
12
|
+
history: { default: 20, maximum: 100 },
|
|
13
|
+
/** The server's dataset bounds: 100 versions and 1,000 rows per page. */
|
|
14
|
+
datasetVersions: { default: 20, maximum: 100 },
|
|
15
|
+
datasetRows: { default: 100, maximum: 1_000 },
|
|
11
16
|
inspect: {
|
|
12
17
|
depth: { default: 2, maximum: 3 },
|
|
13
18
|
objects: { default: 20, maximum: 100 },
|
package/src/run.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { dispatch } from "./commands"
|
|
|
3
3
|
|
|
4
4
|
export interface SandboxInstanceCliMode {
|
|
5
5
|
readonly kind: "sandbox"
|
|
6
|
+
/** The sandbox's credentialed address for the API: the run's token is added on the way out. */
|
|
6
7
|
readonly baseUrl: string
|
|
7
8
|
readonly runContextPath: string
|
|
8
9
|
}
|
|
@@ -36,11 +37,11 @@ export function createInstanceApiClient(mode: InstanceCliMode): ApiClient {
|
|
|
36
37
|
: "The selected Sixb profile has no API URL.",
|
|
37
38
|
unavailableMessage:
|
|
38
39
|
mode.kind === "sandbox"
|
|
39
|
-
? "The Sixb API
|
|
40
|
+
? "The Sixb API could not be reached from the sandbox."
|
|
40
41
|
: "The Sixb API could not be reached.",
|
|
41
42
|
unavailableHint:
|
|
42
43
|
mode.kind === "sandbox"
|
|
43
|
-
? "Run 'sixb
|
|
44
|
+
? "Run 'sixb status' to verify the sandbox runtime and its API access."
|
|
44
45
|
: "Run 'sixb status' to verify the current profile.",
|
|
45
46
|
})
|
|
46
47
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises"
|
|
2
|
+
|
|
3
|
+
/** The `sixb` a sandbox installs: a shell launcher and the bundle it runs on Bun or Node. */
|
|
4
|
+
export interface SandboxCliAssets {
|
|
5
|
+
readonly launcher: string
|
|
6
|
+
readonly artifact: Uint8Array
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let cachedAssets: Promise<SandboxCliAssets> | undefined
|
|
10
|
+
|
|
11
|
+
/** Read from beside this module: `src/` in the workspace, `dist/` once built. */
|
|
12
|
+
export function loadSandboxCliAssets(): Promise<SandboxCliAssets> {
|
|
13
|
+
cachedAssets ??= Promise.all([
|
|
14
|
+
readFile(new URL("./bin/sixb", import.meta.url), "utf8"),
|
|
15
|
+
readFile(new URL("./generated/sixb.mjs", import.meta.url)),
|
|
16
|
+
]).then(([launcher, artifact]) => ({ launcher, artifact }))
|
|
17
|
+
return cachedAssets
|
|
18
|
+
}
|