@nexum-hub/sdk 1.0.1 → 1.0.2-next.34

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 (2) hide show
  1. package/dist/index.d.ts +351 -49
  2. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -4,11 +4,113 @@
4
4
 
5
5
  import { Blob as Blob$1 } from 'node:buffer';
6
6
 
7
+ declare const aliases: {
8
+ readonly auto: "auto";
9
+ readonly utf8: "utf8";
10
+ readonly "utf-8": "utf8";
11
+ readonly cp65001: "utf8";
12
+ readonly utf16le: "utf16le";
13
+ readonly "utf-16le": "utf16le";
14
+ readonly ucs2: "utf16le";
15
+ readonly "ucs-2": "utf16le";
16
+ readonly cp1200: "utf16le";
17
+ readonly utf16be: "utf-16be";
18
+ readonly "utf-16be": "utf-16be";
19
+ readonly cp1201: "utf-16be";
20
+ readonly latin1: "latin1";
21
+ readonly binary: "latin1";
22
+ readonly ascii: "ascii";
23
+ readonly base64: "base64";
24
+ readonly base64url: "base64url";
25
+ readonly hex: "hex";
26
+ readonly gbk: "gbk";
27
+ readonly gb2312: "gbk";
28
+ readonly cp936: "gbk";
29
+ readonly gb18030: "gb18030";
30
+ readonly cp54936: "gb18030";
31
+ readonly shift_jis: "shift_jis";
32
+ readonly "shift-jis": "shift_jis";
33
+ readonly sjis: "shift_jis";
34
+ readonly "windows-31j": "shift_jis";
35
+ readonly cp932: "shift_jis";
36
+ readonly big5: "big5";
37
+ readonly cp950: "big5";
38
+ readonly "euc-kr": "euc-kr";
39
+ readonly cp949: "euc-kr";
40
+ readonly "windows-874": "windows-874";
41
+ readonly cp874: "windows-874";
42
+ readonly ibm866: "ibm866";
43
+ readonly cp866: "ibm866";
44
+ readonly cp437: "cp437";
45
+ readonly cp850: "cp850";
46
+ readonly cp852: "cp852";
47
+ readonly cp855: "cp855";
48
+ readonly cp857: "cp857";
49
+ readonly cp858: "cp858";
50
+ readonly cp860: "cp860";
51
+ readonly cp861: "cp861";
52
+ readonly cp862: "cp862";
53
+ readonly cp863: "cp863";
54
+ readonly cp864: "cp864";
55
+ readonly cp865: "cp865";
56
+ readonly cp869: "cp869";
57
+ readonly "windows-1250": "windows-1250";
58
+ readonly cp1250: "windows-1250";
59
+ readonly "windows-1251": "windows-1251";
60
+ readonly cp1251: "windows-1251";
61
+ readonly "windows-1252": "windows-1252";
62
+ readonly cp1252: "windows-1252";
63
+ readonly "windows-1253": "windows-1253";
64
+ readonly cp1253: "windows-1253";
65
+ readonly "windows-1254": "windows-1254";
66
+ readonly cp1254: "windows-1254";
67
+ readonly "windows-1255": "windows-1255";
68
+ readonly cp1255: "windows-1255";
69
+ readonly "windows-1256": "windows-1256";
70
+ readonly cp1256: "windows-1256";
71
+ readonly "windows-1257": "windows-1257";
72
+ readonly cp1257: "windows-1257";
73
+ readonly "windows-1258": "windows-1258";
74
+ readonly cp1258: "windows-1258";
75
+ };
7
76
  export interface AccessTarget {
8
77
  type: "path" | "url" | "resource" | "connection" | "agent-state" | "user-state" | "transfer" | "maintenance";
9
78
  value: string;
10
79
  access: string;
11
80
  }
81
+ export interface ApiMaintenanceConfig {
82
+ name?: string;
83
+ serviceUrl?: string;
84
+ authentication?: {
85
+ operationSelections?: Record<string, number>;
86
+ credentialBindings?: Record<string, string>;
87
+ /** OpenAPI security scheme objects from the approved specification. */
88
+ supplementalSchemes?: Record<string, JsonObject>;
89
+ supplementalSecurity?: Record<string, string[]>[];
90
+ };
91
+ oauth?: Record<string, ApiOAuthOptions>;
92
+ sourceAuthentication?: {
93
+ type: "none" | "apiKey" | "basic" | "bearer";
94
+ name?: string;
95
+ in?: "header" | "query";
96
+ credentialRef?: string;
97
+ };
98
+ credentialBindings?: Record<string, string>;
99
+ limits?: Partial<Record<"documentBytes" | "totalDocumentBytes" | "referenceCount" | "operationCount" | "requestBytes" | "responseBytes" | "requestTimeoutMs", number>> | null;
100
+ }
101
+ export interface ApiOAuthOptions {
102
+ issuer?: string;
103
+ authorizationEndpoint?: string;
104
+ tokenEndpoint?: string;
105
+ deviceAuthorizationEndpoint?: string;
106
+ jwksUri?: string;
107
+ clientId?: string;
108
+ clientAuthentication?: "" | "none" | "client_secret_basic" | "client_secret_post";
109
+ flow?: "" | "authorizationCode" | "device" | "clientCredentials";
110
+ scopes?: string[];
111
+ oidc?: boolean;
112
+ allowHttp?: boolean;
113
+ }
12
114
  export interface ContributionOrigin extends JsonObject {
13
115
  type: "local" | "platform" | "extension";
14
116
  owner: string;
@@ -42,9 +144,23 @@ export interface HostRequestServices {
42
144
  elicitation(params: JsonObject, options?: HostRequestOptions): Promise<JsonObject>;
43
145
  roots(options?: HostRequestOptions): Promise<JsonObject>;
44
146
  }
147
+ export interface InputAttachment {
148
+ path: string;
149
+ name: string;
150
+ mimeType: string;
151
+ size: number;
152
+ sha256: string;
153
+ revision: string;
154
+ resourceUri: string;
155
+ }
156
+ /** Continuation input does not replace the original context.input. */
157
+ export interface InputReply {
158
+ input: JsonValue;
159
+ attachments: InputAttachment[];
160
+ }
45
161
  export interface InputRequest {
46
162
  message: string;
47
- inputSchema: JsonValue;
163
+ inputSchema: JsonObject | boolean;
48
164
  timeoutMs?: number;
49
165
  }
50
166
  export interface Invocation {
@@ -63,7 +179,7 @@ export interface Invocation {
63
179
  log(entry: LogEntry): void;
64
180
  progress(value: JsonObject): void;
65
181
  authorize(target: AccessTarget): void;
66
- requestInput(request: InputRequest): Promise<JsonObject>;
182
+ requestInput(request: InputRequest): Promise<InputReply>;
67
183
  }
68
184
  export interface LogEntry {
69
185
  level: "debug" | "info" | "warn" | "error";
@@ -86,7 +202,7 @@ export interface MaintenanceListOptions {
86
202
  export interface MaintenanceRequestView {
87
203
  readonly requestId: string;
88
204
  readonly agentId: string;
89
- readonly profile: Binding["profile"];
205
+ readonly profile: "development" | "production";
90
206
  readonly target: MaintenanceTarget;
91
207
  readonly action: string;
92
208
  readonly name: string;
@@ -131,31 +247,15 @@ export interface MaintenanceService {
131
247
  }): Promise<MaintenanceCreated>;
132
248
  };
133
249
  readonly mcp: {
134
- add(input: {
135
- name: string;
136
- config: JsonObject;
137
- }): Promise<MaintenanceCreated>;
138
- update(input: {
139
- name: string;
140
- config: JsonObject;
141
- }): Promise<MaintenanceCreated>;
250
+ add(input: Record<string, McpConnectionOptions>): Promise<MaintenanceCreated>;
251
+ update(input: Record<string, McpConnectionOptions>): Promise<MaintenanceCreated>;
142
252
  remove(input: {
143
253
  name: string;
144
254
  }): Promise<MaintenanceCreated>;
145
255
  };
146
256
  readonly api: {
147
- import(input: {
148
- name: string;
149
- url?: string;
150
- path?: string;
151
- config?: JsonObject;
152
- }): Promise<MaintenanceCreated>;
153
- update(input: {
154
- name: string;
155
- url?: string;
156
- path?: string;
157
- config?: JsonObject;
158
- }): Promise<MaintenanceCreated>;
257
+ import(input: ApiImportOptions): Promise<MaintenanceCreated>;
258
+ update(input: ApiUpdateOptions): Promise<MaintenanceCreated>;
159
259
  remove(input: {
160
260
  name: string;
161
261
  }): Promise<MaintenanceCreated>;
@@ -193,6 +293,8 @@ export interface McpResultOptions {
193
293
  }
194
294
  export interface MethodDefinition {
195
295
  description: string;
296
+ /** The raw JavaScript method accepts exactly one named input object. */
297
+ callStyle?: "input-object";
196
298
  permissions: readonly string[];
197
299
  inputSchema: unknown;
198
300
  schemaDialect?: SchemaDialect;
@@ -249,6 +351,24 @@ export interface OutputSource {
249
351
  mimeType?: string;
250
352
  name?: string;
251
353
  }
354
+ export interface ProcessSnapshot {
355
+ processId: string;
356
+ status: string;
357
+ state: string;
358
+ lifetime: ResourceSnapshot["lifetime"];
359
+ originRunId: string | null;
360
+ contextId: string | null;
361
+ origin: ContributionOrigin;
362
+ createdAt: number;
363
+ closedAt: number | null;
364
+ handedOffAt: number | null;
365
+ controlAvailable: boolean;
366
+ pid: number | null;
367
+ exitCode: number | null;
368
+ signal: string | null;
369
+ outputComplete: boolean;
370
+ details: JsonObject;
371
+ }
252
372
  export interface ResourcePage {
253
373
  /** Byte/scan budgets may shorten a page; nextCursor preserves the remaining position. */
254
374
  readonly items: readonly ResourceSnapshot[];
@@ -297,10 +417,89 @@ export interface ResourceSnapshot extends JsonObject {
297
417
  readonly details: JsonObject;
298
418
  readonly controlAvailable: boolean;
299
419
  }
420
+ export interface RestartReceipt {
421
+ requested: true;
422
+ reason: "apply-approved-updates" | "recover-agent";
423
+ afterRun: string;
424
+ }
425
+ export interface RuntimeSDK {
426
+ sleep(milliseconds: number): Promise<null>;
427
+ requestInput(request: InputRequest): Promise<InputReply>;
428
+ restart(request: {
429
+ reason: RestartReceipt["reason"];
430
+ }): Promise<RestartReceipt>;
431
+ }
432
+ export interface ShSDK {
433
+ exec(options: ExecOptions | string): Promise<ProcessRead>;
434
+ start(options: StartOptions | string): Promise<ProcessSnapshot>;
435
+ get(input: ReadInput): Promise<ProcessRead>;
436
+ list(input?: Omit<ResourceQuery, "kind">): Promise<{
437
+ items: ProcessSnapshot[];
438
+ nextCursor: string | null;
439
+ }>;
440
+ write(input: {
441
+ processId: string;
442
+ data: string | Uint8Array;
443
+ eof?: boolean;
444
+ } | {
445
+ processId: string;
446
+ data?: string | Uint8Array;
447
+ eof: true;
448
+ }): Promise<{
449
+ processId: string;
450
+ accepted: true;
451
+ bytes: number;
452
+ eof: boolean;
453
+ }>;
454
+ resize(input: {
455
+ processId: string;
456
+ cols: number;
457
+ rows: number;
458
+ }): Promise<{
459
+ processId: string;
460
+ accepted: true;
461
+ cols: number;
462
+ rows: number;
463
+ }>;
464
+ signal(input: {
465
+ processId: string;
466
+ signal: NodeJS.Signals;
467
+ }): Promise<{
468
+ processId: string;
469
+ } & ProcessSignalReceipt>;
470
+ stop(input: {
471
+ processId: string;
472
+ graceMs?: number;
473
+ forceMs?: number;
474
+ }): Promise<ProcessStop>;
475
+ which(input: string | {
476
+ command: string;
477
+ cwd?: string;
478
+ }): Promise<Executable>;
479
+ }
480
+ export interface StateDeletion {
481
+ readonly deleted: true;
482
+ readonly version: number;
483
+ readonly updatedAt: number;
484
+ }
485
+ export interface StateNamespace {
486
+ get(key: string): Promise<StateValue | null>;
487
+ set(key: string, value: JsonValue, options: {
488
+ expectedVersion: number | null;
489
+ }): Promise<StateValue>;
490
+ delete(key: string, options: {
491
+ expectedVersion: number;
492
+ }): Promise<StateDeletion>;
493
+ }
300
494
  export interface StateService {
301
495
  readonly agent: StateNamespace;
302
496
  readonly user: StateNamespace;
303
497
  }
498
+ export interface StateValue {
499
+ readonly value: JsonValue;
500
+ readonly version: number;
501
+ readonly updatedAt: number;
502
+ }
304
503
  /** Budget ownership only; neither a filesystem handle nor a native-close proof. */
305
504
  export interface StorageReservation {
306
505
  release(): void;
@@ -315,6 +514,10 @@ export interface TransferListOptions {
315
514
  readonly limit?: number;
316
515
  readonly cursor?: string;
317
516
  }
517
+ export interface TransferSDK extends Omit<TransferService, "createUpload" | "createDownload"> {
518
+ createUpload(options: UploadOptions | string): ReturnType<TransferService["createUpload"]>;
519
+ createDownload(options: DownloadOptions | string): ReturnType<TransferService["createDownload"]>;
520
+ }
318
521
  export interface TransferService {
319
522
  createUpload(options: UploadOptions): Promise<UploadOffer>;
320
523
  createDownload(options: DownloadOptions): Promise<DownloadOffer>;
@@ -338,6 +541,7 @@ export interface TransferSnapshot {
338
541
  readonly runId: string | null;
339
542
  readonly contextId: string | null;
340
543
  readonly projectId: string | null;
544
+ readonly maxBytes: number | null;
341
545
  readonly path?: string;
342
546
  readonly resource?: TransferResource;
343
547
  readonly progress: {
@@ -358,10 +562,32 @@ export interface UploadOptions {
358
562
  readonly expectedSha256?: string;
359
563
  readonly mimeType?: string;
360
564
  }
565
+ export type ApiImportOptions = {
566
+ name: string;
567
+ config?: ApiMaintenanceConfig;
568
+ } & ({
569
+ url: string;
570
+ path?: never;
571
+ } | {
572
+ path: string;
573
+ url?: never;
574
+ });
575
+ export type ApiUpdateOptions = {
576
+ name: string;
577
+ config?: ApiMaintenanceConfig;
578
+ } & ({
579
+ url?: string;
580
+ path?: never;
581
+ } | {
582
+ path?: string;
583
+ url?: never;
584
+ });
361
585
  export type DownloadOffer = TransferSnapshot & TransferOffer & {
362
586
  readonly direction: "download";
363
587
  readonly status: "pending";
364
- readonly resource: TransferResource;
588
+ readonly resource: TransferResource & {
589
+ readonly size: number;
590
+ };
365
591
  readonly expiresAt: string;
366
592
  };
367
593
  export type DownloadOptions = ({
@@ -374,6 +600,10 @@ export type DownloadOptions = ({
374
600
  readonly name?: string;
375
601
  readonly mimeType?: string;
376
602
  };
603
+ export type ExecOptions = LaunchOptions & {
604
+ check?: boolean;
605
+ background?: false;
606
+ };
377
607
  export type ExtensionFactory = (host: ExtensionHost) => ExtensionInstance | Promise<ExtensionInstance>;
378
608
  export type JsonObject = {
379
609
  [key: string]: JsonValue;
@@ -382,7 +612,39 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
382
612
  [key: string]: JsonValue;
383
613
  };
384
614
  export type McpAccess = "result" | "resources.read" | "resources.list";
615
+ export type McpConnectionOptions = ({
616
+ type?: "stdio";
617
+ command: string;
618
+ args?: string[];
619
+ cwd?: string;
620
+ env?: Record<string, string>;
621
+ url?: never;
622
+ headers?: never;
623
+ } | {
624
+ type?: "sse" | "http" | "streamable-http";
625
+ url: string;
626
+ headers?: Record<string, string>;
627
+ command?: never;
628
+ args?: never;
629
+ cwd?: never;
630
+ env?: never;
631
+ }) & {
632
+ credentialBindings?: Record<string, string>;
633
+ };
634
+ export type ProcessRead = ProcessSnapshot & Omit<ProcessOutputPage, "nextCursor"> & {
635
+ nextCursor: string | null;
636
+ };
637
+ export type ProcessStop = {
638
+ processId: string;
639
+ accepted: boolean;
640
+ confirmed: boolean;
641
+ facts: ProcessFacts;
642
+ } & Partial<ProcessSnapshot>;
385
643
  export type SchemaDialect = "draft7" | "2020-12";
644
+ export type StartOptions = LaunchOptions & {
645
+ background?: boolean;
646
+ check?: false;
647
+ };
386
648
  export type UploadOffer = TransferSnapshot & TransferOffer & {
387
649
  readonly direction: "upload";
388
650
  readonly status: "pending";
@@ -402,10 +664,13 @@ interface ArtifactRecord {
402
664
  readonly createdAt: string;
403
665
  readonly expiresAt: string;
404
666
  }
405
- interface Binding {
406
- readonly agentId: string;
407
- readonly profile: Profile;
408
- readonly cloudEnvironment: string;
667
+ interface Executable {
668
+ readonly command: string;
669
+ /** Resolved absolute spelling; preserves executable symlink/argv[0] semantics. */
670
+ readonly launchPath: string;
671
+ readonly path: string;
672
+ readonly kind: "native" | "batch";
673
+ readonly platform: NodeJS.Platform;
409
674
  }
410
675
  interface MaintenanceDecision {
411
676
  readonly status: "approved" | "denied";
@@ -432,6 +697,33 @@ interface MaintenanceSummary {
432
697
  readonly namespace: string | null;
433
698
  readonly restartMayBeRequired: boolean;
434
699
  }
700
+ interface ProcessFacts {
701
+ readonly pid: number | null;
702
+ readonly startedAt: number | null;
703
+ readonly rootExited: boolean;
704
+ readonly exitCode: number | null;
705
+ readonly exitSignal: string | null;
706
+ readonly outputComplete: boolean;
707
+ readonly treeStopped: boolean;
708
+ readonly closed: boolean;
709
+ readonly stopRequested: boolean;
710
+ readonly forceRequested: boolean;
711
+ }
712
+ interface ProcessOutputPage {
713
+ readonly output: {
714
+ stream: ProcessOutputStream;
715
+ data: string | Buffer;
716
+ }[];
717
+ readonly nextCursor: string;
718
+ readonly hasMoreOutput: boolean;
719
+ readonly truncated: boolean;
720
+ readonly outputComplete: boolean;
721
+ }
722
+ interface ProcessSignalReceipt {
723
+ readonly requested: string;
724
+ readonly delivered: boolean;
725
+ readonly mechanism: "process-group" | "job-object" | "terminal-input";
726
+ }
435
727
  interface ResourceRecord {
436
728
  readonly resourceId: string;
437
729
  readonly originRunId: string | null;
@@ -448,25 +740,6 @@ interface ResourceRecord {
448
740
  readonly handedOffAt: number | null;
449
741
  readonly closedAt: number | null;
450
742
  }
451
- interface StateDeletion {
452
- readonly deleted: true;
453
- readonly version: number;
454
- readonly updatedAt: number;
455
- }
456
- interface StateNamespace {
457
- get(key: string): Promise<StateValue | null>;
458
- set(key: string, value: JsonValue, options: {
459
- expectedVersion: number | null;
460
- }): Promise<StateValue>;
461
- delete(key: string, options: {
462
- expectedVersion: number;
463
- }): Promise<StateDeletion>;
464
- }
465
- interface StateValue {
466
- readonly value: JsonValue;
467
- readonly version: number;
468
- readonly updatedAt: number;
469
- }
470
743
  interface UploadFileReceipt {
471
744
  readonly path: string;
472
745
  readonly name: string;
@@ -481,11 +754,38 @@ type IssuedTransferSnapshot = JsonObject & {
481
754
  status: "pending";
482
755
  expiresAt: string;
483
756
  };
757
+ type LaunchOptions = ({
758
+ command: string;
759
+ args?: string[];
760
+ shellCommand?: never;
761
+ shell?: never;
762
+ } | {
763
+ shellCommand: string;
764
+ shell?: string;
765
+ command?: never;
766
+ args?: never;
767
+ }) & {
768
+ cwd?: string;
769
+ env?: Record<string, string | null>;
770
+ tty?: boolean;
771
+ cols?: number;
772
+ rows?: number;
773
+ input?: string | Uint8Array;
774
+ timeoutMs?: number;
775
+ };
484
776
  type MaintenanceAuthStatus = "not_required" | "required" | "ready" | "failed";
485
777
  type MaintenanceStatus = "pending" | "approved" | "denied" | "cancelled" | "expired";
486
778
  type MaintenanceTarget = "package" | "extension" | "mcp" | "api";
487
779
  type McpMethod = "tools/call" | "tools/list" | "resources/list" | "resources/templates/list" | "prompts/list" | "prompts/get";
488
- type Profile = "development" | "production";
780
+ type OutputEncoding = keyof typeof aliases;
781
+ type ProcessOutputStream = "stdout" | "stderr" | "terminal";
782
+ type ReadInput = {
783
+ processId: string;
784
+ cursor?: string;
785
+ maxBytes?: number;
786
+ encoding?: OutputEncoding | null;
787
+ waitMs?: number;
788
+ };
489
789
  type TransferOffer = Readonly<IssuedTransferSnapshot & {
490
790
  request: TransferRequest;
491
791
  }>;
@@ -495,7 +795,9 @@ type TransferRequest = {
495
795
  readonly headers: Readonly<Record<string, string>>;
496
796
  readonly expiresAt: string;
497
797
  };
498
- type TransferResource = Pick<ArtifactRecord, "uri" | "name" | "mimeType" | "size">;
798
+ type TransferResource = Pick<ArtifactRecord, "uri" | "name" | "mimeType"> & {
799
+ readonly size: number | null;
800
+ };
499
801
  type TransferStatus = "preparing" | "pending" | "transferring" | "cancelling" | "succeeded" | "failed" | "cancelled" | "expired" | "interrupted";
500
802
 
501
803
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexum-hub/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2-next.34",
4
4
  "private": false,
5
5
  "description": "Nexum SDK 扩展公共类型协议",
6
6
  "license": "UNLICENSED",
@@ -11,11 +11,11 @@
11
11
  },
12
12
  "publishConfig": {
13
13
  "access": "public",
14
- "tag": "latest"
14
+ "tag": "next"
15
15
  },
16
16
  "type": "module",
17
17
  "engines": {
18
- "node": ">=24.22.1 <25"
18
+ "node": "24.22.1"
19
19
  },
20
20
  "exports": {
21
21
  ".": {