@kmlckj/aios-agent-server-sdk 0.0.0-stage → 0.0.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 (134) hide show
  1. package/EVENTS.md +88 -0
  2. package/README.md +628 -2
  3. package/capabilities.json +2398 -0
  4. package/dist/cli/daemon/preferences.d.ts +67 -0
  5. package/dist/cli/daemon/protocol.d.ts +26 -0
  6. package/dist/cli/daemon/resource-limits.d.ts +39 -0
  7. package/dist/core/auth/platform-client.d.ts +59 -0
  8. package/dist/core/host/runtime-dependencies.d.ts +26 -0
  9. package/dist/core/skills/skill-bindings.d.ts +19 -0
  10. package/dist/core/skills/skill-versions.d.ts +31 -0
  11. package/dist/electron/main/bundled-runtime-tools.d.ts +24 -0
  12. package/dist/events.js +1 -0
  13. package/dist/index.js +55 -0
  14. package/dist/sdk/src/auth.d.ts +43 -0
  15. package/dist/sdk/src/authorization-events.d.ts +16 -0
  16. package/dist/sdk/src/authorization.d.ts +10 -0
  17. package/dist/sdk/src/communication.d.ts +9 -0
  18. package/dist/sdk/src/diagnostics.d.ts +24 -0
  19. package/dist/sdk/src/errors.d.ts +4 -0
  20. package/dist/sdk/src/events.d.ts +4 -0
  21. package/dist/sdk/src/file-api.d.ts +29 -0
  22. package/dist/sdk/src/file-storage.d.ts +34 -0
  23. package/dist/sdk/src/index.d.ts +257 -0
  24. package/dist/sdk/src/local-connection.d.ts +9 -0
  25. package/dist/sdk/src/managed-host.d.ts +32 -0
  26. package/dist/sdk/src/native-status.d.ts +59 -0
  27. package/dist/sdk/src/platform.d.ts +35 -0
  28. package/dist/sdk/src/runtime-control.d.ts +111 -0
  29. package/dist/sdk/src/runtime-integrity.d.ts +10 -0
  30. package/dist/sdk/src/tool-reference.d.ts +11 -0
  31. package/dist/sdk/src/tool-result.d.ts +36 -0
  32. package/dist/sdk/src/tool-server.d.ts +14 -0
  33. package/dist/sdk/src/transport.d.ts +25 -0
  34. package/dist/sdk/src/types.d.ts +492 -0
  35. package/dist/shared/account-context-api.d.ts +47 -0
  36. package/dist/shared/action-center-api.d.ts +50 -0
  37. package/dist/shared/agent-capabilities.d.ts +42 -0
  38. package/dist/shared/agent-hooks.d.ts +10 -0
  39. package/dist/shared/agent-team.d.ts +17 -0
  40. package/dist/shared/artifact-evidence.d.ts +18 -0
  41. package/dist/shared/automation-api.d.ts +112 -0
  42. package/dist/shared/client-downloads-api.d.ts +20 -0
  43. package/dist/shared/cloud-assistant-api.d.ts +1020 -0
  44. package/dist/shared/cloud-task-event-api.d.ts +22 -0
  45. package/dist/shared/collaboration-api.d.ts +16 -0
  46. package/dist/shared/collaboration-automation-api.d.ts +55 -0
  47. package/dist/shared/collaboration-deep-link.d.ts +18 -0
  48. package/dist/shared/collaboration-event-api.d.ts +19 -0
  49. package/dist/shared/collaboration-plan-api.d.ts +159 -0
  50. package/dist/shared/collaboration-project-api.d.ts +206 -0
  51. package/dist/shared/collaboration-resource-api.d.ts +41 -0
  52. package/dist/shared/collaboration-task-api.d.ts +372 -0
  53. package/dist/shared/computer-use-api.d.ts +80 -0
  54. package/dist/shared/computer-use-handshake.d.ts +19 -0
  55. package/dist/shared/computer-use-protocol.d.ts +488 -0
  56. package/dist/shared/context-usage.d.ts +15 -0
  57. package/dist/shared/desktop-api.d.ts +449 -0
  58. package/dist/shared/desktop-diagnostics-api.d.ts +56 -0
  59. package/dist/shared/desktop-language.d.ts +3 -0
  60. package/dist/shared/desktop-mcp-service-api.d.ts +157 -0
  61. package/dist/shared/document-session-api.d.ts +91 -0
  62. package/dist/shared/enterprise-knowledge-api.d.ts +103 -0
  63. package/dist/shared/enterprise-project-api.d.ts +26 -0
  64. package/dist/shared/execution-activity.d.ts +3 -0
  65. package/dist/shared/execution-context.d.ts +37 -0
  66. package/dist/shared/execution-identity.d.ts +7 -0
  67. package/dist/shared/execution-profile.d.ts +6 -0
  68. package/dist/shared/execution-target.d.ts +71 -0
  69. package/dist/shared/expert-team-api.d.ts +54 -0
  70. package/dist/shared/feedback-api.d.ts +20 -0
  71. package/dist/shared/git-api.d.ts +227 -0
  72. package/dist/shared/git-http-api.d.ts +12 -0
  73. package/dist/shared/hosted-git-api.d.ts +132 -0
  74. package/dist/shared/js-agent-hooks.d.ts +23 -0
  75. package/dist/shared/local-custom-model-api.d.ts +55 -0
  76. package/dist/shared/local-environment-api.d.ts +110 -0
  77. package/dist/shared/local-mcp-server-api.d.ts +91 -0
  78. package/dist/shared/local-memory.d.ts +165 -0
  79. package/dist/shared/local-plugin-api.d.ts +26 -0
  80. package/dist/shared/local-runtime-api.d.ts +32 -0
  81. package/dist/shared/local-skill-api.d.ts +42 -0
  82. package/dist/shared/local-task-api.d.ts +658 -0
  83. package/dist/shared/local-task-command-client.d.ts +55 -0
  84. package/dist/shared/local-task-command.d.ts +91 -0
  85. package/dist/shared/local-task-event-projection.d.ts +29 -0
  86. package/dist/shared/local-task-projection.d.ts +29 -0
  87. package/dist/shared/local-workspace.d.ts +9 -0
  88. package/dist/shared/managed-authorization.d.ts +70 -0
  89. package/dist/shared/memory-customization.d.ts +32 -0
  90. package/dist/shared/model-routing.d.ts +31 -0
  91. package/dist/shared/model-selection.d.ts +11 -0
  92. package/dist/shared/my-expert-api.d.ts +119 -0
  93. package/dist/shared/navigation-api.d.ts +20 -0
  94. package/dist/shared/office-window-api.d.ts +81 -0
  95. package/dist/shared/platform-branding-api.d.ts +66 -0
  96. package/dist/shared/plugin-market-api.d.ts +120 -0
  97. package/dist/shared/profession-market-api.d.ts +96 -0
  98. package/dist/shared/project-local-skill-api.d.ts +8 -0
  99. package/dist/shared/remote-connection-api.d.ts +97 -0
  100. package/dist/shared/remote-connection.d.ts +62 -0
  101. package/dist/shared/remote-installation-api.d.ts +50 -0
  102. package/dist/shared/remote-tasks-api.d.ts +118 -0
  103. package/dist/shared/runtime-tuning.d.ts +44 -0
  104. package/dist/shared/scene-case-api.d.ts +42 -0
  105. package/dist/shared/security-center-api.d.ts +74 -0
  106. package/dist/shared/sensitive-protection-api.d.ts +71 -0
  107. package/dist/shared/session-policy.d.ts +26 -0
  108. package/dist/shared/shortcut-api.d.ts +7 -0
  109. package/dist/shared/skill-activation-api.d.ts +8 -0
  110. package/dist/shared/skill-asset-api.d.ts +12 -0
  111. package/dist/shared/skill-market-api.d.ts +119 -0
  112. package/dist/shared/skill-upload.d.ts +16 -0
  113. package/dist/shared/speech-recognition-api.d.ts +12 -0
  114. package/dist/shared/storage-integrity.d.ts +15 -0
  115. package/dist/shared/target-bridge-protocol.d.ts +67 -0
  116. package/dist/shared/target-environments.d.ts +15 -0
  117. package/dist/shared/target-resources.d.ts +105 -0
  118. package/dist/shared/task-initialization-api.d.ts +44 -0
  119. package/dist/shared/task-menu-api.d.ts +27 -0
  120. package/dist/shared/task-operation.d.ts +19 -0
  121. package/dist/shared/task-path-policy.d.ts +14 -0
  122. package/dist/shared/task-resource-manifest.d.ts +33 -0
  123. package/dist/shared/task-storage-recovery.d.ts +33 -0
  124. package/dist/shared/task-terminal-api.d.ts +48 -0
  125. package/dist/shared/team-control.d.ts +60 -0
  126. package/dist/shared/tool-activity.d.ts +18 -0
  127. package/dist/shared/update-api.d.ts +65 -0
  128. package/dist/shared/usage-statistics-api.d.ts +18 -0
  129. package/dist/shared/worktree-api.d.ts +188 -0
  130. package/examples/business-assistant.mjs +19 -0
  131. package/examples/common.mjs +51 -0
  132. package/examples/platform-assistant.mjs +9 -0
  133. package/examples/standalone-assistant.mjs +16 -0
  134. package/package.json +20 -4
@@ -0,0 +1,33 @@
1
+ /** Auditable preparation metadata only. Never contains secrets, tokens, full
2
+ * service configuration, or controller-local filesystem paths. */
3
+ export interface TaskResourceManifest {
4
+ schemaVersion: 1;
5
+ preparedAt: string;
6
+ configuration: {
7
+ mcpRevision: string;
8
+ modelRevision: string;
9
+ };
10
+ skills: Array<{
11
+ id: string;
12
+ source: string;
13
+ scope?: string;
14
+ version?: string;
15
+ revision?: string;
16
+ contentHash: string;
17
+ selected: boolean;
18
+ available: boolean;
19
+ }>;
20
+ plugins: Array<{
21
+ id: string;
22
+ runtimeId?: string;
23
+ version?: string;
24
+ definitionHash: string;
25
+ }>;
26
+ expert?: {
27
+ id: string;
28
+ versionId: string;
29
+ version: string;
30
+ packageHash?: string;
31
+ instructionsHash?: string;
32
+ };
33
+ }
@@ -0,0 +1,33 @@
1
+ import type { LocalTaskMessage } from './local-task-api.js';
2
+ import type { StorageProblem } from './storage-integrity.js';
3
+ export interface TaskStorageProblem {
4
+ file: string;
5
+ status: StorageProblem;
6
+ message: string;
7
+ offset?: number;
8
+ endOffset?: number;
9
+ }
10
+ export interface TaskStorageReport {
11
+ taskId: string;
12
+ status: 'healthy' | 'partial' | 'unrecoverable' | 'temporarily_unavailable';
13
+ checkedAt: string;
14
+ issues: TaskStorageProblem[];
15
+ issueCount: number;
16
+ messages: LocalTaskMessage[];
17
+ messagesSource?: 'checkpoint';
18
+ messagesLimited: boolean;
19
+ validMessageCount: number;
20
+ canRestore: boolean;
21
+ checkpointAt?: string;
22
+ checkpointBytes?: number;
23
+ fingerprint: string;
24
+ protectionIssue?: string;
25
+ /** Missing live external references do not invalidate the task journals. */
26
+ resourceIssues?: TaskStorageProblem[];
27
+ }
28
+ export interface TaskStorageRecoveryApi {
29
+ inspect: (taskId: string) => Promise<TaskStorageReport>;
30
+ restore: (taskId: string, fingerprint: string) => Promise<TaskStorageReport>;
31
+ cancel: (taskId: string) => Promise<void>;
32
+ createFromRecovered: (taskId: string, fingerprint: string) => Promise<import('./local-task-api.js').LocalTask>;
33
+ }
@@ -0,0 +1,48 @@
1
+ export interface TaskTerminalTarget {
2
+ taskId: string;
3
+ tabId: string;
4
+ }
5
+ export interface TaskTerminalSize {
6
+ cols: number;
7
+ rows: number;
8
+ }
9
+ export type TaskTerminalEvent = TaskTerminalTarget & {
10
+ sequence: number;
11
+ } & ({
12
+ type: 'output';
13
+ dataBase64: string;
14
+ } | {
15
+ type: 'exit';
16
+ exitCode: number;
17
+ } | {
18
+ type: 'error';
19
+ message: string;
20
+ });
21
+ export interface TaskTerminalSnapshot {
22
+ cwd: string;
23
+ events: TaskTerminalEvent[];
24
+ running: boolean;
25
+ }
26
+ export type TaskTerminalStateUpdate = {
27
+ status: 'connected';
28
+ snapshot: TaskTerminalSnapshot;
29
+ } | {
30
+ status: 'disconnected' | 'error';
31
+ message: string;
32
+ };
33
+ export type TaskTerminalState = TaskTerminalTarget & TaskTerminalStateUpdate;
34
+ export interface TaskTerminalApi {
35
+ open(request: TaskTerminalTarget & {
36
+ worktreeId?: string;
37
+ size: TaskTerminalSize;
38
+ }): Promise<TaskTerminalSnapshot>;
39
+ write(request: TaskTerminalTarget & {
40
+ data: string;
41
+ }): Promise<void>;
42
+ resize(request: TaskTerminalTarget & {
43
+ size: TaskTerminalSize;
44
+ }): Promise<void>;
45
+ close(request: TaskTerminalTarget): Promise<void>;
46
+ onEvent(listener: (event: TaskTerminalEvent) => void): () => void;
47
+ onState(listener: (state: TaskTerminalState) => void): () => void;
48
+ }
@@ -0,0 +1,60 @@
1
+ export interface TeamMemberState {
2
+ memberRunId: string;
3
+ memberId: string;
4
+ threadId: string;
5
+ status: string;
6
+ displayName: string;
7
+ finalText?: string;
8
+ error?: string;
9
+ createdAt: string;
10
+ completedAt?: string;
11
+ closedAt?: string;
12
+ }
13
+ export interface TeamTaskState {
14
+ workflowTaskId: string;
15
+ teamRunId: string;
16
+ subject: string;
17
+ description: string;
18
+ ownerMemberId: string;
19
+ blockedBy: string[];
20
+ status: string;
21
+ revision: number;
22
+ }
23
+ export interface TeamState {
24
+ teamRunId: string;
25
+ taskSnapshotHash: string;
26
+ status: string;
27
+ ownerAvailable: boolean;
28
+ members: TeamMemberState[];
29
+ tasks: TeamTaskState[];
30
+ }
31
+ export type TeamCommand = {
32
+ action: 'task.create';
33
+ subject: string;
34
+ description: string;
35
+ ownerMemberId: string;
36
+ blockedBy?: string[];
37
+ } | {
38
+ action: 'task.update';
39
+ taskId: string;
40
+ expectedRevision: number;
41
+ status: 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
42
+ } | {
43
+ action: 'delegate' | 'followUp';
44
+ memberId: string;
45
+ taskId: string;
46
+ message: string;
47
+ } | {
48
+ action: 'wait';
49
+ memberIds: string[];
50
+ } | {
51
+ action: 'stop' | 'close';
52
+ memberId: string;
53
+ };
54
+ export interface TeamCommandResult {
55
+ success: boolean;
56
+ contentItems: Array<{
57
+ type: string;
58
+ text: string;
59
+ }>;
60
+ }
@@ -0,0 +1,18 @@
1
+ type RecordValue = Record<string, unknown>;
2
+ export type ToolActivityCategory = 'file' | 'browser' | 'command' | 'mcp';
3
+ export interface ToolActivityTitle {
4
+ title: string;
5
+ category?: ToolActivityCategory;
6
+ }
7
+ export interface ToolDisplayIdentity {
8
+ provider?: string;
9
+ operation?: string;
10
+ external?: boolean;
11
+ }
12
+ export declare function activityRecord(value: unknown): RecordValue;
13
+ /** Strip URL credentials, queries and fragments before shortening; never display script/body contents. */
14
+ export declare function safeActivityText(value: string): string;
15
+ /** Exact known namespaces only. A third-party tool called read_file is not our file tool. */
16
+ export declare function activityToolName(payload: RecordValue): string;
17
+ export declare function toolActivityTitle(payload: RecordValue, language?: 'zh-CN' | 'en-US', identity?: ToolDisplayIdentity, protect?: (value: string) => string): ToolActivityTitle | undefined;
18
+ export {};
@@ -0,0 +1,65 @@
1
+ export type ClientReleasePlatform = 'WINDOWS' | 'MACOS_INTEL' | 'MACOS_APPLE_SILICON' | 'LINUX_X64' | 'LINUX_ARM64';
2
+ export type ClientReleaseChannel = 'STABLE' | 'BETA' | 'CANARY';
3
+ export type ClientUpdateReason = 'NO_RELEASE' | 'UP_TO_DATE' | 'UPDATE_AVAILABLE' | 'DOWNGRADE_AVAILABLE' | 'ROLLOUT_HOLD' | 'RELEASE_NOT_READY';
4
+ export interface ClientUpdateCheckRequest {
5
+ platform: ClientReleasePlatform;
6
+ architecture: string;
7
+ currentVersion: string;
8
+ currentBuildNumber: number;
9
+ osVersion: string;
10
+ channel: ClientReleaseChannel;
11
+ installationId: string;
12
+ }
13
+ export interface ClientUpdateRelease {
14
+ platform: ClientReleasePlatform;
15
+ version: string;
16
+ buildNumber: number;
17
+ channel: ClientReleaseChannel;
18
+ releaseNotes?: string | null;
19
+ minimumOsVersion?: string | null;
20
+ publishedAt?: string | null;
21
+ activatedAt?: string | null;
22
+ }
23
+ export interface ClientUpdatePackage {
24
+ type: 'FULL' | 'DELTA';
25
+ fromBuildNumber?: number | null;
26
+ downloadUrl: string;
27
+ fileSizeBytes: number;
28
+ checksumSha256: string;
29
+ signature: string;
30
+ signatureAlgorithm: string;
31
+ }
32
+ export interface ClientUpdateCheckResult {
33
+ updateAvailable: boolean;
34
+ required: boolean;
35
+ downgrade: boolean;
36
+ reason: ClientUpdateReason;
37
+ checkAfterSeconds: number;
38
+ release?: ClientUpdateRelease | null;
39
+ updatePackage?: ClientUpdatePackage | null;
40
+ }
41
+ export type DesktopUpdateStatus = 'idle' | 'checking' | 'up-to-date' | 'available' | 'downloading' | 'downloaded' | 'installing' | 'error';
42
+ export interface DesktopUpdateState {
43
+ status: DesktopUpdateStatus;
44
+ currentVersion: string;
45
+ currentBuildNumber: number;
46
+ canInstallAutomatically: boolean;
47
+ osSupported?: boolean;
48
+ osCompatibilityMessage?: string;
49
+ checkedAt?: string;
50
+ result?: ClientUpdateCheckResult;
51
+ progressPercent?: number;
52
+ bytesDownloaded?: number;
53
+ totalBytes?: number;
54
+ deferredUntil?: string;
55
+ error?: string;
56
+ }
57
+ export interface DesktopUpdatesApi {
58
+ getState: () => Promise<DesktopUpdateState>;
59
+ check: () => Promise<DesktopUpdateState>;
60
+ download: () => Promise<DesktopUpdateState>;
61
+ install: () => Promise<void>;
62
+ defer: () => Promise<DesktopUpdateState>;
63
+ openDownloadPage: () => Promise<void>;
64
+ onStateChanged: (listener: (state: DesktopUpdateState) => void) => () => void;
65
+ }
@@ -0,0 +1,18 @@
1
+ export interface UsageStatisticsDay {
2
+ date: string;
3
+ callCount: number;
4
+ totalTokens: number;
5
+ }
6
+ export interface UsageStatisticsModelDay extends UsageStatisticsDay {
7
+ modelName: string | null;
8
+ }
9
+ export interface PersonalUsageStatistics {
10
+ totalTokens: number;
11
+ days: UsageStatisticsDay[];
12
+ modelDays: UsageStatisticsModelDay[];
13
+ }
14
+ export interface UsageStatisticsApi {
15
+ getStatistics: (query: {
16
+ endDate: string;
17
+ }) => Promise<PersonalUsageStatistics>;
18
+ }
@@ -0,0 +1,188 @@
1
+ import type { GitCheckout, GitFailure, GitResult, GitTarget, RepositoryCommand } from './git-api.js';
2
+ import type { LocalTask } from './local-task-api.js';
3
+ import type { LocalEnvironmentFile } from './local-environment-api.js';
4
+ export interface WorktreeSettings {
5
+ rootDirectory: string;
6
+ fetchBeforeCreate: boolean;
7
+ automaticCleanup?: boolean;
8
+ retainedCount?: number;
9
+ }
10
+ export declare const DEFAULT_WORKTREE_SETTINGS: WorktreeSettings;
11
+ export interface WorktreeScript {
12
+ common: string;
13
+ darwin?: string;
14
+ linux?: string;
15
+ win32?: string;
16
+ }
17
+ export interface WorktreeEnvironment {
18
+ version: 1;
19
+ id: string;
20
+ repositoryId: string;
21
+ ownerUserId: string;
22
+ name: string;
23
+ setup: WorktreeScript;
24
+ cleanup?: WorktreeScript;
25
+ actions?: Array<{
26
+ id: string;
27
+ name: string;
28
+ script: WorktreeScript;
29
+ platform?: 'darwin' | 'linux' | 'win32';
30
+ }>;
31
+ }
32
+ export interface SaveWorktreeEnvironmentRequest {
33
+ taskId: string;
34
+ checkoutId: string;
35
+ id?: string;
36
+ name: string;
37
+ setup: WorktreeScript;
38
+ cleanup?: WorktreeScript;
39
+ actions?: WorktreeEnvironment['actions'];
40
+ }
41
+ export interface WorktreeAssociation {
42
+ taskId: string;
43
+ kind: 'default' | 'attachment';
44
+ }
45
+ export interface ManagedWorktree {
46
+ version: 1;
47
+ id: string;
48
+ ownerUserId: string;
49
+ projectId?: string;
50
+ repositoryId: string;
51
+ sourcePath: string;
52
+ commonGitDir: string;
53
+ path: string;
54
+ name: string;
55
+ head: string;
56
+ createdAt: string;
57
+ operationId: string;
58
+ state: 'ready' | 'initialization-failed' | 'archived';
59
+ associations: WorktreeAssociation[];
60
+ environmentId?: string;
61
+ retained?: boolean;
62
+ snapshot?: WorktreeSnapshot;
63
+ projectRelativePath?: string;
64
+ sourceWorkspacePath?: string;
65
+ localWorkspaceId?: string;
66
+ }
67
+ export interface WorktreeListItem extends ManagedWorktree {
68
+ available: boolean;
69
+ revision?: string;
70
+ tasks: Array<{
71
+ id: string;
72
+ name: string;
73
+ status: LocalTask['status'];
74
+ kind: WorktreeAssociation['kind'];
75
+ }>;
76
+ }
77
+ export interface CreateWorktreeRequest extends GitTarget {
78
+ requestId: string;
79
+ expectedRevision: string;
80
+ ref?: string;
81
+ remote?: string;
82
+ name?: string;
83
+ basis?: 'ref' | 'working-state';
84
+ environmentId?: string;
85
+ includeIgnored?: string[];
86
+ credentialId?: string;
87
+ }
88
+ export type WorktreePhase = 'awaiting-authorization' | 'preparing' | 'fetching' | 'creating' | 'copying' | 'initializing' | 'registering' | 'completed' | 'failed' | 'cancelled' | 'interrupted';
89
+ export type WorktreeCommand = RepositoryCommand;
90
+ export interface WorktreeOperation {
91
+ version: 1;
92
+ id: string;
93
+ worktreeId: string;
94
+ taskId: string;
95
+ ownerUserId: string;
96
+ projectId?: string;
97
+ request: CreateWorktreeRequest;
98
+ source: GitCheckout;
99
+ sourceRef: string;
100
+ head: string;
101
+ path: string;
102
+ name: string;
103
+ phase: WorktreePhase;
104
+ completedSteps: string[];
105
+ createdAt: string;
106
+ updatedAt: string;
107
+ commands: WorktreeCommand[];
108
+ fetchRemote?: string;
109
+ environment?: WorktreeEnvironment;
110
+ registered: boolean;
111
+ directoryCreated: boolean;
112
+ defaultCwdChanged: false;
113
+ error?: GitFailure;
114
+ projectRelativePath?: string;
115
+ sourceWorkspacePath?: string;
116
+ localEnvironment?: LocalEnvironmentFile;
117
+ }
118
+ export interface WorktreeSnapshot {
119
+ commit: string;
120
+ tree: string;
121
+ parent: string;
122
+ ref: string;
123
+ createdAt: string;
124
+ includedIgnored: string[];
125
+ }
126
+ export interface WorktreeLifecycleRequest {
127
+ taskId?: string;
128
+ worktreeId: string;
129
+ requestId: string;
130
+ action: 'archive' | 'restore' | 'environment-action';
131
+ expectedRevision?: string;
132
+ includeIgnored?: string[];
133
+ actionId?: string;
134
+ confirmed?: boolean;
135
+ }
136
+ export interface WorktreeLifecycleOperation {
137
+ version: 1;
138
+ id: string;
139
+ ownerUserId: string;
140
+ request: WorktreeLifecycleRequest;
141
+ worktree: ManagedWorktree;
142
+ phase: 'awaiting-authorization' | 'snapshotting' | 'removing' | 'restoring' | 'initializing' | 'completed' | 'failed' | 'interrupted';
143
+ commands: RepositoryCommand[];
144
+ filePaths: string[];
145
+ completedSteps: string[];
146
+ createdAt: string;
147
+ updatedAt: string;
148
+ snapshot?: WorktreeSnapshot;
149
+ error?: GitFailure;
150
+ automaticCleanup?: boolean;
151
+ }
152
+ export interface WorktreeApi {
153
+ list(taskId?: string): Promise<GitResult<WorktreeListItem[]>>;
154
+ status(request: {
155
+ taskId: string;
156
+ operationId: string;
157
+ }): Promise<GitResult<WorktreeOperation>>;
158
+ cancel(request: {
159
+ taskId: string;
160
+ operationId: string;
161
+ }): Promise<GitResult<WorktreeOperation>>;
162
+ newTask(request: {
163
+ taskId?: string;
164
+ worktreeId: string;
165
+ name?: string;
166
+ }): Promise<GitResult<LocalTask>>;
167
+ listEnvironments(target: GitTarget): Promise<GitResult<WorktreeEnvironment[]>>;
168
+ saveEnvironment(request: SaveWorktreeEnvironmentRequest): Promise<GitResult<WorktreeEnvironment>>;
169
+ removeEnvironment(request: {
170
+ taskId: string;
171
+ checkoutId: string;
172
+ id: string;
173
+ }): Promise<GitResult<void>>;
174
+ prepareLifecycle(request: WorktreeLifecycleRequest): Promise<GitResult<WorktreeLifecycleOperation>>;
175
+ executeLifecycle(request: {
176
+ taskId?: string;
177
+ operationId: string;
178
+ }): Promise<GitResult<WorktreeLifecycleOperation>>;
179
+ lifecycleStatus(request: {
180
+ taskId?: string;
181
+ operationId: string;
182
+ }): Promise<GitResult<WorktreeLifecycleOperation>>;
183
+ retain(request: {
184
+ taskId?: string;
185
+ worktreeId: string;
186
+ retained: boolean;
187
+ }): Promise<GitResult<void>>;
188
+ }
@@ -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,22 @@
1
1
  {
2
2
  "name": "@kmlckj/aios-agent-server-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "AIOS agent application SDK for Node.js",
5
+ "type": "module",
6
+ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
7
+ "engines": { "node": "^22.23.2 || ^24.0.0" },
8
+ "dependencies": { "ajv": "8.20.0", "tar": "7.5.22" },
9
+ "optionalDependencies": {
10
+ "@kmlckj/aios-runtime-win32-x64": "0.0.1",
11
+ "@kmlckj/aios-runtime-darwin-x64": "0.0.1",
12
+ "@kmlckj/aios-runtime-darwin-arm64": "0.0.1",
13
+ "@kmlckj/aios-runtime-linux-x64": "0.0.1",
14
+ "@kmlckj/aios-runtime-linux-arm64": "0.0.1"
15
+ },
16
+ "exports": {
17
+ ".": { "types": "./dist/sdk/src/index.d.ts", "import": "./dist/index.js" },
18
+ "./events": { "types": "./dist/sdk/src/events.d.ts", "import": "./dist/events.js" }
19
+ },
20
+ "files": ["dist", "README.md", "EVENTS.md", "examples", "capabilities.json"],
21
+ "license": "UNLICENSED"
22
+ }