@kmlckj/aios-agent-server-sdk 0.0.0-stage → 0.0.2
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/EVENTS.md +88 -0
- package/README.md +656 -2
- package/capabilities.json +2398 -0
- package/dist/cli/daemon/preferences.d.ts +67 -0
- package/dist/cli/daemon/protocol.d.ts +26 -0
- package/dist/cli/daemon/resource-limits.d.ts +39 -0
- package/dist/core/auth/platform-client.d.ts +65 -0
- package/dist/core/host/runtime-dependencies.d.ts +26 -0
- package/dist/core/skills/skill-bindings.d.ts +19 -0
- package/dist/core/skills/skill-versions.d.ts +31 -0
- package/dist/electron/main/bundled-runtime-tools.d.ts +24 -0
- package/dist/events.js +1 -0
- package/dist/index.js +55 -0
- package/dist/sdk/src/auth.d.ts +43 -0
- package/dist/sdk/src/authorization-events.d.ts +16 -0
- package/dist/sdk/src/authorization.d.ts +10 -0
- package/dist/sdk/src/communication.d.ts +9 -0
- package/dist/sdk/src/diagnostics.d.ts +24 -0
- package/dist/sdk/src/errors.d.ts +4 -0
- package/dist/sdk/src/events.d.ts +4 -0
- package/dist/sdk/src/file-api.d.ts +29 -0
- package/dist/sdk/src/file-storage.d.ts +34 -0
- package/dist/sdk/src/index.d.ts +260 -0
- package/dist/sdk/src/local-connection.d.ts +9 -0
- package/dist/sdk/src/managed-host.d.ts +32 -0
- package/dist/sdk/src/native-status.d.ts +59 -0
- package/dist/sdk/src/platform.d.ts +39 -0
- package/dist/sdk/src/runtime-control.d.ts +111 -0
- package/dist/sdk/src/runtime-integrity.d.ts +10 -0
- package/dist/sdk/src/tool-reference.d.ts +11 -0
- package/dist/sdk/src/tool-result.d.ts +36 -0
- package/dist/sdk/src/tool-server.d.ts +14 -0
- package/dist/sdk/src/transport.d.ts +25 -0
- package/dist/sdk/src/types.d.ts +405 -0
- package/dist/shared/account-context-api.d.ts +47 -0
- package/dist/shared/account-schedules-api.d.ts +110 -0
- package/dist/shared/action-center-api.d.ts +50 -0
- package/dist/shared/agent-capabilities.d.ts +42 -0
- package/dist/shared/agent-hooks.d.ts +10 -0
- package/dist/shared/agent-team.d.ts +19 -0
- package/dist/shared/artifact-evidence.d.ts +18 -0
- package/dist/shared/automation-api.d.ts +112 -0
- package/dist/shared/client-downloads-api.d.ts +20 -0
- package/dist/shared/cloud-assistant-api.d.ts +532 -0
- package/dist/shared/cloud-task-resources.d.ts +24 -0
- package/dist/shared/cloud-task-runtime-api.d.ts +253 -0
- package/dist/shared/collaboration-api.d.ts +17 -0
- package/dist/shared/collaboration-automation-api.d.ts +55 -0
- package/dist/shared/collaboration-deep-link.d.ts +15 -0
- package/dist/shared/collaboration-event-api.d.ts +19 -0
- package/dist/shared/collaboration-plan-api.d.ts +159 -0
- package/dist/shared/collaboration-project-api.d.ts +206 -0
- package/dist/shared/collaboration-resource-api.d.ts +41 -0
- package/dist/shared/collaboration-task-api.d.ts +276 -0
- package/dist/shared/collaboration-task-execution.d.ts +39 -0
- package/dist/shared/computer-use-api.d.ts +80 -0
- package/dist/shared/computer-use-handshake.d.ts +19 -0
- package/dist/shared/computer-use-protocol.d.ts +488 -0
- package/dist/shared/context-usage.d.ts +15 -0
- package/dist/shared/desktop-api.d.ts +450 -0
- package/dist/shared/desktop-diagnostics-api.d.ts +56 -0
- package/dist/shared/desktop-language.d.ts +3 -0
- package/dist/shared/desktop-mcp-service-api.d.ts +157 -0
- package/dist/shared/document-session-api.d.ts +91 -0
- package/dist/shared/enterprise-knowledge-api.d.ts +103 -0
- package/dist/shared/enterprise-project-api.d.ts +26 -0
- package/dist/shared/execution-activity.d.ts +3 -0
- package/dist/shared/execution-context.d.ts +62 -0
- package/dist/shared/execution-identity.d.ts +7 -0
- package/dist/shared/execution-profile.d.ts +6 -0
- package/dist/shared/execution-target.d.ts +71 -0
- package/dist/shared/expert-selection.d.ts +22 -0
- package/dist/shared/expert-team-api.d.ts +54 -0
- package/dist/shared/feedback-api.d.ts +20 -0
- package/dist/shared/git-api.d.ts +227 -0
- package/dist/shared/git-http-api.d.ts +12 -0
- package/dist/shared/hosted-git-api.d.ts +132 -0
- package/dist/shared/js-agent-hooks.d.ts +23 -0
- package/dist/shared/local-custom-model-api.d.ts +55 -0
- package/dist/shared/local-environment-api.d.ts +110 -0
- package/dist/shared/local-mcp-server-api.d.ts +91 -0
- package/dist/shared/local-memory.d.ts +165 -0
- package/dist/shared/local-plugin-api.d.ts +26 -0
- package/dist/shared/local-runtime-api.d.ts +32 -0
- package/dist/shared/local-skill-api.d.ts +42 -0
- package/dist/shared/local-task-api.d.ts +658 -0
- package/dist/shared/local-task-command-client.d.ts +55 -0
- package/dist/shared/local-task-command.d.ts +93 -0
- package/dist/shared/local-task-event-projection.d.ts +29 -0
- package/dist/shared/local-task-projection.d.ts +29 -0
- package/dist/shared/local-workspace.d.ts +9 -0
- package/dist/shared/managed-authorization.d.ts +72 -0
- package/dist/shared/memory-customization.d.ts +32 -0
- package/dist/shared/model-routing.d.ts +31 -0
- package/dist/shared/model-selection.d.ts +11 -0
- package/dist/shared/my-expert-api.d.ts +119 -0
- package/dist/shared/navigation-api.d.ts +20 -0
- package/dist/shared/office-window-api.d.ts +81 -0
- package/dist/shared/platform-branding-api.d.ts +66 -0
- package/dist/shared/plugin-market-api.d.ts +120 -0
- package/dist/shared/profession-market-api.d.ts +96 -0
- package/dist/shared/project-local-skill-api.d.ts +8 -0
- package/dist/shared/remote-connection-api.d.ts +97 -0
- package/dist/shared/remote-connection.d.ts +62 -0
- package/dist/shared/remote-installation-api.d.ts +50 -0
- package/dist/shared/remote-tasks-api.d.ts +118 -0
- package/dist/shared/runtime-tuning.d.ts +44 -0
- package/dist/shared/scene-case-api.d.ts +42 -0
- package/dist/shared/sdk-session-contract.d.ts +96 -0
- package/dist/shared/security-center-api.d.ts +74 -0
- package/dist/shared/sensitive-protection-api.d.ts +71 -0
- package/dist/shared/session-policy.d.ts +26 -0
- package/dist/shared/shortcut-api.d.ts +7 -0
- package/dist/shared/skill-activation-api.d.ts +8 -0
- package/dist/shared/skill-asset-api.d.ts +12 -0
- package/dist/shared/skill-market-api.d.ts +119 -0
- package/dist/shared/skill-upload.d.ts +16 -0
- package/dist/shared/speech-recognition-api.d.ts +12 -0
- package/dist/shared/storage-integrity.d.ts +15 -0
- package/dist/shared/target-bridge-protocol.d.ts +67 -0
- package/dist/shared/target-environments.d.ts +15 -0
- package/dist/shared/target-resources.d.ts +105 -0
- package/dist/shared/task-enterprise-project-api.d.ts +75 -0
- package/dist/shared/task-execution-api.d.ts +35 -0
- package/dist/shared/task-initialization-api.d.ts +44 -0
- package/dist/shared/task-menu-api.d.ts +27 -0
- package/dist/shared/task-operation.d.ts +19 -0
- package/dist/shared/task-path-policy.d.ts +14 -0
- package/dist/shared/task-resource-manifest.d.ts +33 -0
- package/dist/shared/task-storage-recovery.d.ts +33 -0
- package/dist/shared/task-terminal-api.d.ts +48 -0
- package/dist/shared/team-control.d.ts +60 -0
- package/dist/shared/tool-activity.d.ts +18 -0
- package/dist/shared/update-api.d.ts +65 -0
- package/dist/shared/usage-statistics-api.d.ts +18 -0
- package/dist/shared/worktree-api.d.ts +188 -0
- package/examples/business-assistant.mjs +19 -0
- package/examples/common.mjs +51 -0
- package/examples/platform-assistant.mjs +9 -0
- package/examples/standalone-assistant.mjs +16 -0
- package/package.json +40 -4
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { platformClient, observe, required } from './common.mjs';
|
|
4
|
+
const workspace = path.resolve(required('AIOS_WORKSPACE'));
|
|
5
|
+
const client = await platformClient('sdk-business-example', { tools: false, skills: false });
|
|
6
|
+
try {
|
|
7
|
+
const agent = await client.defineAgent({ id: 'orders', version: '1', name: '订单助手', model: required('AIOS_MODEL'),
|
|
8
|
+
instructions: '通过业务工具查询订单,按月份统计金额,然后调用保存工具发起写入审批。保存工具本身会请求用户审批,无需在普通文本中重复询问;未获批准不得宣称保存成功。只能依据查询结果作答。',
|
|
9
|
+
tools: [{ name: 'query_orders', description: '查询示例订单', readOnly: true,
|
|
10
|
+
inputSchema: { type: 'object', properties: { month: { type: 'string', pattern: '^2026-10$' } }, required: ['month'], additionalProperties: false },
|
|
11
|
+
execute: () => ({ orders: [{ id: 'A1', amount: 120 }, { id: 'A2', amount: 80 }], currency: 'CNY' }) },
|
|
12
|
+
{ name: 'save_summary', description: '保存经过用户确认的订单摘要', readOnly: false,
|
|
13
|
+
inputSchema: { type: 'object', properties: { count: { type: 'integer' }, total: { type: 'number' } }, required: ['count', 'total'], additionalProperties: false },
|
|
14
|
+
execute: async (input, { signal }) => { signal.throwIfAborted(); await fs.writeFile(path.join(workspace, 'order-summary.json'), JSON.stringify(input, null, 2), { flag: 'wx', signal }); return { saved: true }; } }],
|
|
15
|
+
});
|
|
16
|
+
const session = await agent.createSession({ workspacePath: workspace, name: 'SDK 业务工具示例' });
|
|
17
|
+
console.log(JSON.stringify({ taskId: session.id }));
|
|
18
|
+
await observe(await session.send('查询 2026-10 的订单,汇总条数和金额,然后调用保存工具发起摘要写入审批。'));
|
|
19
|
+
} finally { await client.close(); }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createInterface } from 'node:readline/promises';
|
|
3
|
+
import { createClient } from '@kmlckj/aios-agent-server-sdk';
|
|
4
|
+
|
|
5
|
+
export function required(name) {
|
|
6
|
+
const value = process.env[name];
|
|
7
|
+
if (!value) throw new Error(`Missing environment variable: ${name}`);
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
export function runtime() {
|
|
11
|
+
return { ...(process.env.AIOS_RUNTIME_DIRECTORY ? { directory: path.resolve(process.env.AIOS_RUNTIME_DIRECTORY) } : {}), dataDirectory: path.resolve(required('AIOS_DATA_DIRECTORY')),
|
|
12
|
+
...(process.env.AIOS_NODE_EXECUTABLE ? { nodeExecutable: process.env.AIOS_NODE_EXECUTABLE } : {}),
|
|
13
|
+
...(process.env.AIOS_CHROMIUM ? { chromiumExecutable: process.env.AIOS_CHROMIUM } : {}) };
|
|
14
|
+
}
|
|
15
|
+
export async function platformClient(appId, builtins) {
|
|
16
|
+
const client = await createClient({ mode: 'platform', appId, userScope: required('AIOS_USER_SCOPE'), appName: 'AIOS SDK 示例',
|
|
17
|
+
platformBaseUrl: required('AIOS_PLATFORM_URL'), runtime: runtime(), builtins });
|
|
18
|
+
try {
|
|
19
|
+
if (process.env.AIOS_BROWSER_LOGIN === '1') {
|
|
20
|
+
const login = await client.auth.startBrowserLogin(); console.log(await login.getAuthorizationUrl()); await login.wait();
|
|
21
|
+
} else {
|
|
22
|
+
const login = await client.auth.login({ loginType: 'USERNAME', account: required('AIOS_ACCOUNT'), password: required('AIOS_PASSWORD') });
|
|
23
|
+
if (login.status !== 'authenticated') throw new Error('Platform requires a password change. Complete it with auth.completePasswordChange first.');
|
|
24
|
+
}
|
|
25
|
+
return client;
|
|
26
|
+
} catch (error) { await client.close(); throw error; }
|
|
27
|
+
}
|
|
28
|
+
export async function observe(run) {
|
|
29
|
+
const handled = new Set();
|
|
30
|
+
for await (const event of run.events()) {
|
|
31
|
+
if (event.type === 'approval_required' || event.type === 'user_input_required') {
|
|
32
|
+
const state = await run.state();
|
|
33
|
+
for (const interaction of state.interactions) {
|
|
34
|
+
if (handled.has(interaction.id)) continue;
|
|
35
|
+
handled.add(interaction.id);
|
|
36
|
+
if (interaction.kind === 'approval') {
|
|
37
|
+
const terminal = process.env.AIOS_APPROVE_WRITES === '1' ? undefined : createInterface({ input: process.stdin, output: process.stdout });
|
|
38
|
+
let approve;
|
|
39
|
+
try { approve = !terminal || (await terminal.question('Approve this tool operation? [y/N] ')).toLowerCase() === 'y'; }
|
|
40
|
+
finally { terminal?.close(); }
|
|
41
|
+
await run.approve(String(interaction.payload.tool_call_id), approve ? 'approve' : 'deny');
|
|
42
|
+
} else throw new Error(`Input required: ${interaction.requestId}. Respond with run.answer using the supplied interaction schema.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
console.log(JSON.stringify({ type: event.type, id: event.id, runId: event.runId }));
|
|
46
|
+
}
|
|
47
|
+
const state = await run.state();
|
|
48
|
+
console.log(JSON.stringify({ runId: run.id, status: state.status, messages: state.messages.filter(message => message.role === 'assistant').map(message => message.content) }));
|
|
49
|
+
if (state.status !== 'completed') throw new Error(`Run finished with status: ${state.status}`);
|
|
50
|
+
return state;
|
|
51
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { platformClient, observe, required } from './common.mjs';
|
|
2
|
+
const client = await platformClient('sdk-platform-example', { tools: { categories: ['workspace', 'documents', 'data'] }, skills: { categories: ['documents'] } });
|
|
3
|
+
try {
|
|
4
|
+
const agent = await client.defineAgent({ id: 'report', version: '1', name: '报告助手', model: required('AIOS_MODEL'),
|
|
5
|
+
instructions: '根据工作目录中的真实材料生成报告。不得编造数据,完成后给出产物路径。' });
|
|
6
|
+
const session = await agent.createSession({ workspacePath: required('AIOS_WORKSPACE'), name: 'SDK 平台报告示例' });
|
|
7
|
+
console.log(JSON.stringify({ taskId: session.id }));
|
|
8
|
+
await observe(await session.send(process.env.AIOS_PROMPT ?? '读取 orders.json,按部门汇总金额并生成 report.md,注明合计和数据条数。'));
|
|
9
|
+
} finally { await client.close(); }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createClient } from '@kmlckj/aios-agent-server-sdk';
|
|
2
|
+
import { runtime, required, observe } from './common.mjs';
|
|
3
|
+
const client = await createClient({ mode: 'standalone', appId: 'sdk-inventory-example', userScope: required('AIOS_USER_SCOPE'), runtime: runtime(),
|
|
4
|
+
builtins: { tools: false, skills: false }, models: [{ id: 'external', endpoint: required('AIOS_MODEL_ENDPOINT'), model: required('AIOS_MODEL'),
|
|
5
|
+
protocol: process.env.AIOS_MODEL_PROTOCOL ?? 'chat_completions', apiKey: process.env.AIOS_MODEL_API_KEY,
|
|
6
|
+
contextWindow: Number(process.env.AIOS_CONTEXT_WINDOW ?? 32768), functionCalling: true }] });
|
|
7
|
+
try {
|
|
8
|
+
const agent = await client.defineAgent({ id: 'inventory', version: '1', name: '库存助手', model: 'external',
|
|
9
|
+
instructions: '只使用应用提供的库存查询工具回答,不假定存在平台账号或内置工具。',
|
|
10
|
+
tools: [{ name: 'query_inventory', description: '查询产品当前库存', readOnly: true,
|
|
11
|
+
inputSchema: { type: 'object', properties: { product: { type: 'string' } }, required: ['product'], additionalProperties: false },
|
|
12
|
+
execute: ({ product }) => ({ product, stock: product === '示例产品' ? 35 : 0 }) }] });
|
|
13
|
+
const session = await agent.createSession({ workspacePath: required('AIOS_WORKSPACE'), name: 'SDK 独立应用示例' });
|
|
14
|
+
console.log(JSON.stringify({ taskId: session.id, mode: (await client.getConfiguration()).mode }));
|
|
15
|
+
if (process.env.AIOS_EXAMPLE_VALIDATE_ONLY !== '1') await observe(await session.send('查询示例产品还有多少库存。'));
|
|
16
|
+
} finally { await client.close(); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kmlckj/aios-agent-server-sdk",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "AIOS agent application SDK for Node.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": "^22.23.2 || ^24.0.0"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"ajv": "8.20.0",
|
|
15
|
+
"tar": "7.5.22"
|
|
16
|
+
},
|
|
17
|
+
"optionalDependencies": {
|
|
18
|
+
"@kmlckj/aios-runtime-win32-x64": "0.0.2",
|
|
19
|
+
"@kmlckj/aios-runtime-darwin-x64": "0.0.2",
|
|
20
|
+
"@kmlckj/aios-runtime-darwin-arm64": "0.0.2",
|
|
21
|
+
"@kmlckj/aios-runtime-linux-x64": "0.0.2",
|
|
22
|
+
"@kmlckj/aios-runtime-linux-arm64": "0.0.2"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/sdk/src/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./events": {
|
|
30
|
+
"types": "./dist/sdk/src/events.d.ts",
|
|
31
|
+
"import": "./dist/events.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"EVENTS.md",
|
|
38
|
+
"examples",
|
|
39
|
+
"capabilities.json"
|
|
40
|
+
],
|
|
41
|
+
"license": "UNLICENSED"
|
|
42
|
+
}
|