buckyos 0.7.168 → 0.7.169
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/cli/core/app.ts +2 -0
- package/cli/dist/cli.mjs +294 -146
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/modules/app.ts +7 -0
- package/cli/modules/ext_tools.ts +71 -0
- package/cli/modules/pikg.ts +7 -1
- package/cli/modules/pikg_protocol.ts +13 -2
- package/cli/modules/skill.ts +31 -6
- package/cli/version.ts +1 -1
- package/package.json +1 -1
package/cli/modules/app.ts
CHANGED
|
@@ -792,6 +792,13 @@ async function mutateLifecycle(
|
|
|
792
792
|
return { ...submitted, status: task }
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
+
/** A local `.pikg` staged for an inspection or import that is not an App install. */
|
|
796
|
+
export async function stageLocalPikg(ctx: CommandContext, path: string): Promise<PikgStagingMetadata> {
|
|
797
|
+
const prepared = await prepareSource(ctx, { pikg: path }, 'inspect', {})
|
|
798
|
+
if (prepared.kind === 'catalog') throw new UsageError('INVALID_PIKG_SOURCE', 'not a local PIKG')
|
|
799
|
+
return prepared.staging
|
|
800
|
+
}
|
|
801
|
+
|
|
795
802
|
async function prepareSource(
|
|
796
803
|
ctx: CommandContext,
|
|
797
804
|
input: Record<string, unknown>,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { CommandDefinition, CommandModule, JsonSchema } from '../core/command.ts'
|
|
2
|
+
import type { CommandContext } from '../core/context.ts'
|
|
3
|
+
import { UsageError } from '../core/errors.ts'
|
|
4
|
+
import { stageLocalPikg } from './app.ts'
|
|
5
|
+
|
|
6
|
+
const OBJECT_OUTPUT: JsonSchema = { type: 'object', additionalProperties: true }
|
|
7
|
+
const ID = { type: 'string' as const, minLength: 1 }
|
|
8
|
+
|
|
9
|
+
function call<T = Record<string, unknown>>(ctx: CommandContext, method: string, params: Record<string, unknown>): Promise<T> {
|
|
10
|
+
return ctx.clients.call('control-panel', method, params, {
|
|
11
|
+
traceId: ctx.traceId, signal: ctx.signal, timeoutMs: Math.max(1, (ctx.deadline ?? Date.now() + 60000) - Date.now()),
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function requestOf(input: Record<string, unknown>, enabled: boolean): Record<string, unknown> {
|
|
16
|
+
const id = typeof input.id === 'string' ? input.id : ''
|
|
17
|
+
if (!id) throw new UsageError('MISSING_ARGUMENT', 'a package id is required')
|
|
18
|
+
return { id, enabled, ...(typeof input.version === 'string' ? { version: input.version } : {}) }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function read(verb: string, summary: string, method: string): CommandDefinition {
|
|
22
|
+
return {
|
|
23
|
+
verb, summary,
|
|
24
|
+
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
25
|
+
outputSchema: OBJECT_OUTPUT, resultSchemaVersion: 1, access: { mode: 'fixed', level: 'read' },
|
|
26
|
+
asyncMode: 'sync', requiresSession: true,
|
|
27
|
+
handler: (ctx) => call(ctx, method, {}),
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function desired(verb: string, summary: string, enabled: boolean): CommandDefinition {
|
|
32
|
+
const properties: Record<string, JsonSchema> = { id: ID, ...(enabled ? { version: { type: 'string', minLength: 1 } } : {}), dry_run: { type: 'boolean' } }
|
|
33
|
+
return {
|
|
34
|
+
verb, summary,
|
|
35
|
+
positionals: [{ name: 'id', description: 'Package id, e.g. ext-core' }],
|
|
36
|
+
options: [
|
|
37
|
+
...(enabled ? [{ name: 'version', description: 'A published version; the newest without it', type: 'string' as const }] : []),
|
|
38
|
+
{ name: 'dry-run', property: 'dry_run', description: 'Only show what would change', type: 'boolean' as const },
|
|
39
|
+
],
|
|
40
|
+
inputSchema: { type: 'object', properties, required: ['id'], additionalProperties: false },
|
|
41
|
+
outputSchema: OBJECT_OUTPUT, resultSchemaVersion: 1, access: { mode: 'fixed', level: 'write' },
|
|
42
|
+
asyncMode: 'sync', requiresSession: true,
|
|
43
|
+
handler: (ctx, input) => call(ctx, input.dry_run === true ? 'ext_tools.plan' : 'ext_tools.set_desired', requestOf(input, enabled)),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The Zone's extension packages. The administrator says what the Zone should have; each node's reconciler gets there. */
|
|
48
|
+
export function createExtToolsModule(): CommandModule {
|
|
49
|
+
return {
|
|
50
|
+
name: 'ext-tools',
|
|
51
|
+
summary: 'Manage the extension tool packages every Agent of the Zone shares',
|
|
52
|
+
commands: [
|
|
53
|
+
read('list', 'The packages published in the Repo, and what each provides', 'ext_tools.catalog'),
|
|
54
|
+
read('status', 'Package by node: what is asked for and where each node got to', 'ext_tools.status'),
|
|
55
|
+
desired('enable', 'Enable or upgrade a package, with the packages it requires', true),
|
|
56
|
+
desired('disable', 'Disable a package; refused while an enabled package requires it', false),
|
|
57
|
+
{
|
|
58
|
+
verb: 'import',
|
|
59
|
+
summary: 'Put an already built .pikg (an official release asset) into the Repo unchanged',
|
|
60
|
+
positionals: [{ name: 'pikg', description: 'Local .pikg file' }],
|
|
61
|
+
inputSchema: { type: 'object', properties: { pikg: { type: 'string', minLength: 1 } }, required: ['pikg'], additionalProperties: false },
|
|
62
|
+
outputSchema: OBJECT_OUTPUT, resultSchemaVersion: 1, access: { mode: 'fixed', level: 'write' },
|
|
63
|
+
asyncMode: 'sync', requiresSession: true,
|
|
64
|
+
handler: async (ctx, input) => {
|
|
65
|
+
const staging = await stageLocalPikg(ctx, String(input.pikg))
|
|
66
|
+
return await call(ctx, 'ext_tools.import', { handle: staging.handle })
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
}
|
|
71
|
+
}
|
package/cli/modules/pikg.ts
CHANGED
|
@@ -676,7 +676,13 @@ async function writeExtToolsSkeleton(dir: string, id: string, version: string, p
|
|
|
676
676
|
windows ? `@echo off\r\necho ${id} ${version}\r\n` : `#!/bin/sh\necho "${id} ${version}"\n`,
|
|
677
677
|
{ mode: 0o755 },
|
|
678
678
|
)
|
|
679
|
-
await host.writeTextFile(
|
|
679
|
+
await host.writeTextFile(
|
|
680
|
+
join(payload, 'smoke', windows ? `${id}.ps1` : `${id}.sh`),
|
|
681
|
+
windows
|
|
682
|
+
? `$ErrorActionPreference = 'Continue'\n& ${id} --version | Out-Null\nif ($LASTEXITCODE -ne 0) { exit 1 }\n`
|
|
683
|
+
: `#!/bin/sh\nset -eu\n${id} --version >/dev/null\n`,
|
|
684
|
+
{ mode: 0o755 },
|
|
685
|
+
)
|
|
680
686
|
}
|
|
681
687
|
|
|
682
688
|
async function readExtToolsManifestFile(path: string): Promise<{ text: string; manifest?: ExtToolsManifest; errors: string[] }> {
|
|
@@ -545,6 +545,15 @@ export const EXT_TOOLS_APP_TYPE = 'ext_tools'
|
|
|
545
545
|
export const EXT_TOOLS_MANIFEST_FILE = 'ext-manifest.json'
|
|
546
546
|
export const EXT_TOOLS_MANIFEST_SCHEMA = 'buckyos.ext_tools/1'
|
|
547
547
|
const MAX_EXT_TOOLS_PAYLOAD_BYTES = 64 * 1024 * 1024 * 1024
|
|
548
|
+
/** The standard layer's commands (Rust: `EXT_TOOLS_RESERVED_COMMANDS`, `baseline::STANDARD_TOOLS`): `tools/bin` comes first
|
|
549
|
+
* on the PATH, so a package providing one would shadow an Agent's identity and control commands. */
|
|
550
|
+
export const EXT_TOOLS_RESERVED_COMMANDS = [
|
|
551
|
+
'agent-session', 'agent_tool', 'ai_provider', 'ai_provider_test', 'ai_quota', 'aicc-tool', 'ask_user', 'buckyos',
|
|
552
|
+
'caption_image', 'detect_image', 'edit_image', 'edit_video', 'enhance_audio', 'extend_video', 'gen_image', 'gen_music',
|
|
553
|
+
'gen_video', 'import_office', 'import_table', 'inpaint_image', 'llm_understand_media', 'materialize_resource',
|
|
554
|
+
'ocr_image', 'remove_bg', 'resume_aicc_task', 'segment_image', 'speech_to_text', 'text_to_speech', 'upscale_image',
|
|
555
|
+
'upscale_video', 'xagent',
|
|
556
|
+
]
|
|
548
557
|
const MAX_EXT_TOOLS_LAUNCHER_BYTES = 1024 * 1024
|
|
549
558
|
const EXT_TOOLS_ID = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/
|
|
550
559
|
const EXT_TOOLS_COMMAND = /^[A-Za-z0-9_+-][A-Za-z0-9._+-]*$/
|
|
@@ -592,7 +601,7 @@ export function extToolsManifestErrors(value: unknown): string[] {
|
|
|
592
601
|
for (const key of Object.keys(manifest)) if (!allowed.includes(key)) errors.push(`${key} is not a field of the manifest`)
|
|
593
602
|
if (manifest.schema !== EXT_TOOLS_MANIFEST_SCHEMA) errors.push(`schema must be ${EXT_TOOLS_MANIFEST_SCHEMA}`)
|
|
594
603
|
if (typeof manifest.id !== 'string' || !EXT_TOOLS_ID.test(manifest.id)) errors.push('id must be lowercase letters, digits and -')
|
|
595
|
-
if (typeof manifest.version !== 'string' ||
|
|
604
|
+
if (typeof manifest.version !== 'string' || !/^[A-Za-z0-9._+-]+$/.test(manifest.version)) errors.push('version must be letters, digits and ._+-')
|
|
596
605
|
if (!Array.isArray(manifest.provides) || manifest.provides.length === 0) errors.push('provides must not be empty')
|
|
597
606
|
const commands = new Set<string>()
|
|
598
607
|
for (const raw of Array.isArray(manifest.provides) ? manifest.provides : []) {
|
|
@@ -603,6 +612,7 @@ export function extToolsManifestErrors(value: unknown): string[] {
|
|
|
603
612
|
continue
|
|
604
613
|
}
|
|
605
614
|
if (commands.has(command)) errors.push(`provides: command ${command} is listed twice`)
|
|
615
|
+
if (EXT_TOOLS_RESERVED_COMMANDS.includes(command)) errors.push(`provides: ${command} is a standard command and cannot be provided by a package`)
|
|
606
616
|
commands.add(command)
|
|
607
617
|
if (typeof entry.version_probe !== 'string' || !entry.version_probe.trim()) errors.push(`provides: ${command} has no version_probe`)
|
|
608
618
|
const smoke = entry.smoke
|
|
@@ -671,7 +681,8 @@ export function extToolsPayloadErrors(manifest: ExtToolsManifest, platform: stri
|
|
|
671
681
|
const launcher = suffixes.map((suffix) => tree.files.get(`bin/${provided.command}${suffix}`)).find(Boolean)
|
|
672
682
|
if (!launcher) errors.push(`bin/${provided.command}: the launcher of a provided command is missing`)
|
|
673
683
|
else if (!windows && !launcher.executable) errors.push(`bin/${provided.command}: the launcher is not executable`)
|
|
674
|
-
|
|
684
|
+
const smoke = provided.smoke && windows ? provided.smoke.replace(/\.[^./]+$/, '.ps1') : provided.smoke
|
|
685
|
+
if (smoke && !tree.files.has(smoke)) errors.push(`${smoke}: the smoke script of ${provided.command} is missing`)
|
|
675
686
|
}
|
|
676
687
|
for (const path of tree.files.keys()) {
|
|
677
688
|
if (!path.startsWith('bin/')) continue
|
package/cli/modules/skill.ts
CHANGED
|
@@ -62,6 +62,27 @@ export function createSkillModule(): CommandModule {
|
|
|
62
62
|
return { agent_id: agentId, ...(kind ? { kind } : {}), total: skills.length, skills }
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
|
+
{
|
|
66
|
+
verb: 'status',
|
|
67
|
+
summary: 'The commands each cmd skill relies on, on a runtime of the Agent, and the extension package that would bring what is missing',
|
|
68
|
+
options: [
|
|
69
|
+
AGENT_OPTION,
|
|
70
|
+
{ name: 'runtime', property: 'runtime_id', description: 'Runtime id (default: the private runtime)', type: 'string' },
|
|
71
|
+
],
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: { agent_id: { type: 'string', minLength: 1 }, runtime_id: { type: 'string', minLength: 1 } },
|
|
75
|
+
required: ['agent_id'],
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
},
|
|
78
|
+
outputSchema: OBJECT_OUTPUT,
|
|
79
|
+
resultSchemaVersion: 1,
|
|
80
|
+
access: { mode: 'fixed', level: 'read' },
|
|
81
|
+
asyncMode: 'sync',
|
|
82
|
+
requiresSession: true,
|
|
83
|
+
examples: ['buckyos skill status --agent jarvis.example.zone --runtime host'],
|
|
84
|
+
handler: async (ctx, input) => await callService<Record<string, unknown>>(ctx, agentIdFrom(input), 'skills.status', { runtime_id: input.runtime_id ?? null }),
|
|
85
|
+
},
|
|
65
86
|
{
|
|
66
87
|
verb: 'install',
|
|
67
88
|
summary: 'Install the skills of a skill PIKG into an Agent',
|
|
@@ -162,21 +183,25 @@ async function installSkills(
|
|
|
162
183
|
}
|
|
163
184
|
files[entry.path] = { content: base64(entry.bytes), executable: entry.executable }
|
|
164
185
|
}
|
|
186
|
+
const skillPackage = {
|
|
187
|
+
package: inspection.app.name,
|
|
188
|
+
version: inspection.app.version,
|
|
189
|
+
pikg_digest: inspection.pikg_digest,
|
|
190
|
+
files,
|
|
191
|
+
}
|
|
165
192
|
const result = await callService<unknown>(ctx, agentId, 'skills.install', {
|
|
166
|
-
package:
|
|
167
|
-
package: inspection.app.name,
|
|
168
|
-
version: inspection.app.version,
|
|
169
|
-
pikg_digest: inspection.pikg_digest,
|
|
170
|
-
files,
|
|
171
|
-
},
|
|
193
|
+
package: skillPackage,
|
|
172
194
|
replace: input.replace === true,
|
|
173
195
|
})
|
|
196
|
+
// Advice, after the fact: a skill is never refused for a command it does not find.
|
|
197
|
+
const commands = await callService<Record<string, unknown>>(ctx, agentId, 'skills.install_plan', { package: skillPackage }).catch(() => null)
|
|
174
198
|
return {
|
|
175
199
|
agent_id: agentId,
|
|
176
200
|
pikg_path: inspection.pikg_path,
|
|
177
201
|
pikg_digest: inspection.pikg_digest,
|
|
178
202
|
...expectObject(result, 'skills.install'),
|
|
179
203
|
...(ignored.length ? { ignored_files: ignored } : {}),
|
|
204
|
+
...(commands ? { commands } : {}),
|
|
180
205
|
}
|
|
181
206
|
}
|
|
182
207
|
|
package/cli/version.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/generate-cli-version.mjs. Do not edit.
|
|
2
|
-
export const PACKAGE_VERSION = '0.7.
|
|
2
|
+
export const PACKAGE_VERSION = '0.7.169'
|
|
3
3
|
export const TOOL_VERSION = PACKAGE_VERSION
|
|
4
4
|
export const SDK_VERSION = PACKAGE_VERSION
|
|
5
5
|
export const PROTOCOL_VERSION = '1'
|