@nexum-hub/sdk 1.0.1-next.29 → 1.0.2-next.32

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 +281 -49
  2. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -9,6 +9,39 @@ export interface AccessTarget {
9
9
  value: string;
10
10
  access: string;
11
11
  }
12
+ export interface ApiMaintenanceConfig {
13
+ name?: string;
14
+ serviceUrl?: string;
15
+ authentication?: {
16
+ operationSelections?: Record<string, number>;
17
+ credentialBindings?: Record<string, string>;
18
+ /** OpenAPI security scheme objects from the approved specification. */
19
+ supplementalSchemes?: Record<string, JsonObject>;
20
+ supplementalSecurity?: Record<string, string[]>[];
21
+ };
22
+ oauth?: Record<string, ApiOAuthOptions>;
23
+ sourceAuthentication?: {
24
+ type: "none" | "apiKey" | "basic" | "bearer";
25
+ name?: string;
26
+ in?: "header" | "query";
27
+ credentialRef?: string;
28
+ };
29
+ credentialBindings?: Record<string, string>;
30
+ limits?: Partial<Record<"documentBytes" | "totalDocumentBytes" | "referenceCount" | "operationCount" | "requestBytes" | "responseBytes" | "requestTimeoutMs", number>> | null;
31
+ }
32
+ export interface ApiOAuthOptions {
33
+ issuer?: string;
34
+ authorizationEndpoint?: string;
35
+ tokenEndpoint?: string;
36
+ deviceAuthorizationEndpoint?: string;
37
+ jwksUri?: string;
38
+ clientId?: string;
39
+ clientAuthentication?: "" | "none" | "client_secret_basic" | "client_secret_post";
40
+ flow?: "" | "authorizationCode" | "device" | "clientCredentials";
41
+ scopes?: string[];
42
+ oidc?: boolean;
43
+ allowHttp?: boolean;
44
+ }
12
45
  export interface ContributionOrigin extends JsonObject {
13
46
  type: "local" | "platform" | "extension";
14
47
  owner: string;
@@ -42,9 +75,23 @@ export interface HostRequestServices {
42
75
  elicitation(params: JsonObject, options?: HostRequestOptions): Promise<JsonObject>;
43
76
  roots(options?: HostRequestOptions): Promise<JsonObject>;
44
77
  }
78
+ export interface InputAttachment {
79
+ path: string;
80
+ name: string;
81
+ mimeType: string;
82
+ size: number;
83
+ sha256: string;
84
+ revision: string;
85
+ resourceUri: string;
86
+ }
87
+ /** Continuation input does not replace the original context.input. */
88
+ export interface InputReply {
89
+ input: JsonValue;
90
+ attachments: InputAttachment[];
91
+ }
45
92
  export interface InputRequest {
46
93
  message: string;
47
- inputSchema: JsonValue;
94
+ inputSchema: JsonObject | boolean;
48
95
  timeoutMs?: number;
49
96
  }
50
97
  export interface Invocation {
@@ -63,7 +110,7 @@ export interface Invocation {
63
110
  log(entry: LogEntry): void;
64
111
  progress(value: JsonObject): void;
65
112
  authorize(target: AccessTarget): void;
66
- requestInput(request: InputRequest): Promise<JsonObject>;
113
+ requestInput(request: InputRequest): Promise<InputReply>;
67
114
  }
68
115
  export interface LogEntry {
69
116
  level: "debug" | "info" | "warn" | "error";
@@ -86,7 +133,7 @@ export interface MaintenanceListOptions {
86
133
  export interface MaintenanceRequestView {
87
134
  readonly requestId: string;
88
135
  readonly agentId: string;
89
- readonly profile: Binding["profile"];
136
+ readonly profile: "development" | "production";
90
137
  readonly target: MaintenanceTarget;
91
138
  readonly action: string;
92
139
  readonly name: string;
@@ -131,31 +178,15 @@ export interface MaintenanceService {
131
178
  }): Promise<MaintenanceCreated>;
132
179
  };
133
180
  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>;
181
+ add(input: Record<string, McpConnectionOptions>): Promise<MaintenanceCreated>;
182
+ update(input: Record<string, McpConnectionOptions>): Promise<MaintenanceCreated>;
142
183
  remove(input: {
143
184
  name: string;
144
185
  }): Promise<MaintenanceCreated>;
145
186
  };
146
187
  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>;
188
+ import(input: ApiImportOptions): Promise<MaintenanceCreated>;
189
+ update(input: ApiUpdateOptions): Promise<MaintenanceCreated>;
159
190
  remove(input: {
160
191
  name: string;
161
192
  }): Promise<MaintenanceCreated>;
@@ -193,6 +224,8 @@ export interface McpResultOptions {
193
224
  }
194
225
  export interface MethodDefinition {
195
226
  description: string;
227
+ /** The raw JavaScript method accepts exactly one named input object. */
228
+ callStyle?: "input-object";
196
229
  permissions: readonly string[];
197
230
  inputSchema: unknown;
198
231
  schemaDialect?: SchemaDialect;
@@ -249,6 +282,24 @@ export interface OutputSource {
249
282
  mimeType?: string;
250
283
  name?: string;
251
284
  }
285
+ export interface ProcessSnapshot {
286
+ processId: string;
287
+ status: string;
288
+ state: string;
289
+ lifetime: ResourceSnapshot["lifetime"];
290
+ originRunId: string | null;
291
+ contextId: string | null;
292
+ origin: ContributionOrigin;
293
+ createdAt: number;
294
+ closedAt: number | null;
295
+ handedOffAt: number | null;
296
+ controlAvailable: boolean;
297
+ pid: number | null;
298
+ exitCode: number | null;
299
+ signal: string | null;
300
+ outputComplete: boolean;
301
+ details: JsonObject;
302
+ }
252
303
  export interface ResourcePage {
253
304
  /** Byte/scan budgets may shorten a page; nextCursor preserves the remaining position. */
254
305
  readonly items: readonly ResourceSnapshot[];
@@ -297,10 +348,89 @@ export interface ResourceSnapshot extends JsonObject {
297
348
  readonly details: JsonObject;
298
349
  readonly controlAvailable: boolean;
299
350
  }
351
+ export interface RestartReceipt {
352
+ requested: true;
353
+ reason: "apply-approved-updates" | "recover-agent";
354
+ afterRun: string;
355
+ }
356
+ export interface RuntimeSDK {
357
+ sleep(milliseconds: number): Promise<null>;
358
+ requestInput(request: InputRequest): Promise<InputReply>;
359
+ restart(request: {
360
+ reason: RestartReceipt["reason"];
361
+ }): Promise<RestartReceipt>;
362
+ }
363
+ export interface ShSDK {
364
+ exec(options: ExecOptions | string): Promise<ProcessRead>;
365
+ start(options: StartOptions | string): Promise<ProcessSnapshot>;
366
+ get(input: ReadInput): Promise<ProcessRead>;
367
+ list(input?: Omit<ResourceQuery, "kind">): Promise<{
368
+ items: ProcessSnapshot[];
369
+ nextCursor: string | null;
370
+ }>;
371
+ write(input: {
372
+ processId: string;
373
+ data: string | Uint8Array;
374
+ eof?: boolean;
375
+ } | {
376
+ processId: string;
377
+ data?: string | Uint8Array;
378
+ eof: true;
379
+ }): Promise<{
380
+ processId: string;
381
+ accepted: true;
382
+ bytes: number;
383
+ eof: boolean;
384
+ }>;
385
+ resize(input: {
386
+ processId: string;
387
+ cols: number;
388
+ rows: number;
389
+ }): Promise<{
390
+ processId: string;
391
+ accepted: true;
392
+ cols: number;
393
+ rows: number;
394
+ }>;
395
+ signal(input: {
396
+ processId: string;
397
+ signal: NodeJS.Signals;
398
+ }): Promise<{
399
+ processId: string;
400
+ } & ProcessSignalReceipt>;
401
+ stop(input: {
402
+ processId: string;
403
+ graceMs?: number;
404
+ forceMs?: number;
405
+ }): Promise<ProcessStop>;
406
+ which(input: string | {
407
+ command: string;
408
+ cwd?: string;
409
+ }): Promise<Executable>;
410
+ }
411
+ export interface StateDeletion {
412
+ readonly deleted: true;
413
+ readonly version: number;
414
+ readonly updatedAt: number;
415
+ }
416
+ export interface StateNamespace {
417
+ get(key: string): Promise<StateValue | null>;
418
+ set(key: string, value: JsonValue, options: {
419
+ expectedVersion: number | null;
420
+ }): Promise<StateValue>;
421
+ delete(key: string, options: {
422
+ expectedVersion: number;
423
+ }): Promise<StateDeletion>;
424
+ }
300
425
  export interface StateService {
301
426
  readonly agent: StateNamespace;
302
427
  readonly user: StateNamespace;
303
428
  }
429
+ export interface StateValue {
430
+ readonly value: JsonValue;
431
+ readonly version: number;
432
+ readonly updatedAt: number;
433
+ }
304
434
  /** Budget ownership only; neither a filesystem handle nor a native-close proof. */
305
435
  export interface StorageReservation {
306
436
  release(): void;
@@ -315,6 +445,10 @@ export interface TransferListOptions {
315
445
  readonly limit?: number;
316
446
  readonly cursor?: string;
317
447
  }
448
+ export interface TransferSDK extends Omit<TransferService, "createUpload" | "createDownload"> {
449
+ createUpload(options: UploadOptions | string): ReturnType<TransferService["createUpload"]>;
450
+ createDownload(options: DownloadOptions | string): ReturnType<TransferService["createDownload"]>;
451
+ }
318
452
  export interface TransferService {
319
453
  createUpload(options: UploadOptions): Promise<UploadOffer>;
320
454
  createDownload(options: DownloadOptions): Promise<DownloadOffer>;
@@ -338,6 +472,7 @@ export interface TransferSnapshot {
338
472
  readonly runId: string | null;
339
473
  readonly contextId: string | null;
340
474
  readonly projectId: string | null;
475
+ readonly maxBytes: number | null;
341
476
  readonly path?: string;
342
477
  readonly resource?: TransferResource;
343
478
  readonly progress: {
@@ -358,10 +493,32 @@ export interface UploadOptions {
358
493
  readonly expectedSha256?: string;
359
494
  readonly mimeType?: string;
360
495
  }
496
+ export type ApiImportOptions = {
497
+ name: string;
498
+ config?: ApiMaintenanceConfig;
499
+ } & ({
500
+ url: string;
501
+ path?: never;
502
+ } | {
503
+ path: string;
504
+ url?: never;
505
+ });
506
+ export type ApiUpdateOptions = {
507
+ name: string;
508
+ config?: ApiMaintenanceConfig;
509
+ } & ({
510
+ url?: string;
511
+ path?: never;
512
+ } | {
513
+ path?: string;
514
+ url?: never;
515
+ });
361
516
  export type DownloadOffer = TransferSnapshot & TransferOffer & {
362
517
  readonly direction: "download";
363
518
  readonly status: "pending";
364
- readonly resource: TransferResource;
519
+ readonly resource: TransferResource & {
520
+ readonly size: number;
521
+ };
365
522
  readonly expiresAt: string;
366
523
  };
367
524
  export type DownloadOptions = ({
@@ -374,6 +531,10 @@ export type DownloadOptions = ({
374
531
  readonly name?: string;
375
532
  readonly mimeType?: string;
376
533
  };
534
+ export type ExecOptions = LaunchOptions & {
535
+ check?: boolean;
536
+ background?: false;
537
+ };
377
538
  export type ExtensionFactory = (host: ExtensionHost) => ExtensionInstance | Promise<ExtensionInstance>;
378
539
  export type JsonObject = {
379
540
  [key: string]: JsonValue;
@@ -382,7 +543,39 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
382
543
  [key: string]: JsonValue;
383
544
  };
384
545
  export type McpAccess = "result" | "resources.read" | "resources.list";
546
+ export type McpConnectionOptions = ({
547
+ type?: "stdio";
548
+ command: string;
549
+ args?: string[];
550
+ cwd?: string;
551
+ env?: Record<string, string>;
552
+ url?: never;
553
+ headers?: never;
554
+ } | {
555
+ type?: "sse" | "http" | "streamable-http";
556
+ url: string;
557
+ headers?: Record<string, string>;
558
+ command?: never;
559
+ args?: never;
560
+ cwd?: never;
561
+ env?: never;
562
+ }) & {
563
+ credentialBindings?: Record<string, string>;
564
+ };
565
+ export type ProcessRead = ProcessSnapshot & Omit<ProcessOutputPage, "nextCursor"> & {
566
+ nextCursor: string | null;
567
+ };
568
+ export type ProcessStop = {
569
+ processId: string;
570
+ accepted: boolean;
571
+ confirmed: boolean;
572
+ facts: ProcessFacts;
573
+ } & Partial<ProcessSnapshot>;
385
574
  export type SchemaDialect = "draft7" | "2020-12";
575
+ export type StartOptions = LaunchOptions & {
576
+ background?: boolean;
577
+ check?: false;
578
+ };
386
579
  export type UploadOffer = TransferSnapshot & TransferOffer & {
387
580
  readonly direction: "upload";
388
581
  readonly status: "pending";
@@ -402,10 +595,13 @@ interface ArtifactRecord {
402
595
  readonly createdAt: string;
403
596
  readonly expiresAt: string;
404
597
  }
405
- interface Binding {
406
- readonly agentId: string;
407
- readonly profile: Profile;
408
- readonly cloudEnvironment: string;
598
+ interface Executable {
599
+ readonly command: string;
600
+ /** Resolved absolute spelling; preserves executable symlink/argv[0] semantics. */
601
+ readonly launchPath: string;
602
+ readonly path: string;
603
+ readonly kind: "native" | "batch";
604
+ readonly platform: NodeJS.Platform;
409
605
  }
410
606
  interface MaintenanceDecision {
411
607
  readonly status: "approved" | "denied";
@@ -432,6 +628,33 @@ interface MaintenanceSummary {
432
628
  readonly namespace: string | null;
433
629
  readonly restartMayBeRequired: boolean;
434
630
  }
631
+ interface ProcessFacts {
632
+ readonly pid: number | null;
633
+ readonly startedAt: number | null;
634
+ readonly rootExited: boolean;
635
+ readonly exitCode: number | null;
636
+ readonly exitSignal: string | null;
637
+ readonly outputComplete: boolean;
638
+ readonly treeStopped: boolean;
639
+ readonly closed: boolean;
640
+ readonly stopRequested: boolean;
641
+ readonly forceRequested: boolean;
642
+ }
643
+ interface ProcessOutputPage {
644
+ readonly output: {
645
+ stream: ProcessOutputStream;
646
+ data: string | Buffer;
647
+ }[];
648
+ readonly nextCursor: string;
649
+ readonly hasMoreOutput: boolean;
650
+ readonly truncated: boolean;
651
+ readonly outputComplete: boolean;
652
+ }
653
+ interface ProcessSignalReceipt {
654
+ readonly requested: string;
655
+ readonly delivered: boolean;
656
+ readonly mechanism: "process-group" | "job-object" | "terminal-input";
657
+ }
435
658
  interface ResourceRecord {
436
659
  readonly resourceId: string;
437
660
  readonly originRunId: string | null;
@@ -448,25 +671,6 @@ interface ResourceRecord {
448
671
  readonly handedOffAt: number | null;
449
672
  readonly closedAt: number | null;
450
673
  }
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
674
  interface UploadFileReceipt {
471
675
  readonly path: string;
472
676
  readonly name: string;
@@ -481,11 +685,37 @@ type IssuedTransferSnapshot = JsonObject & {
481
685
  status: "pending";
482
686
  expiresAt: string;
483
687
  };
688
+ type LaunchOptions = ({
689
+ command: string;
690
+ args?: string[];
691
+ shellCommand?: never;
692
+ shell?: never;
693
+ } | {
694
+ shellCommand: string;
695
+ shell?: string;
696
+ command?: never;
697
+ args?: never;
698
+ }) & {
699
+ cwd?: string;
700
+ env?: Record<string, string | null>;
701
+ tty?: boolean;
702
+ cols?: number;
703
+ rows?: number;
704
+ input?: string | Uint8Array;
705
+ timeoutMs?: number;
706
+ };
484
707
  type MaintenanceAuthStatus = "not_required" | "required" | "ready" | "failed";
485
708
  type MaintenanceStatus = "pending" | "approved" | "denied" | "cancelled" | "expired";
486
709
  type MaintenanceTarget = "package" | "extension" | "mcp" | "api";
487
710
  type McpMethod = "tools/call" | "tools/list" | "resources/list" | "resources/templates/list" | "prompts/list" | "prompts/get";
488
- type Profile = "development" | "production";
711
+ type ProcessOutputStream = "stdout" | "stderr" | "terminal";
712
+ type ReadInput = {
713
+ processId: string;
714
+ cursor?: string;
715
+ maxBytes?: number;
716
+ encoding?: BufferEncoding | null;
717
+ waitMs?: number;
718
+ };
489
719
  type TransferOffer = Readonly<IssuedTransferSnapshot & {
490
720
  request: TransferRequest;
491
721
  }>;
@@ -495,7 +725,9 @@ type TransferRequest = {
495
725
  readonly headers: Readonly<Record<string, string>>;
496
726
  readonly expiresAt: string;
497
727
  };
498
- type TransferResource = Pick<ArtifactRecord, "uri" | "name" | "mimeType" | "size">;
728
+ type TransferResource = Pick<ArtifactRecord, "uri" | "name" | "mimeType"> & {
729
+ readonly size: number | null;
730
+ };
499
731
  type TransferStatus = "preparing" | "pending" | "transferring" | "cancelling" | "succeeded" | "failed" | "cancelled" | "expired" | "interrupted";
500
732
 
501
733
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexum-hub/sdk",
3
- "version": "1.0.1-next.29",
3
+ "version": "1.0.2-next.32",
4
4
  "private": false,
5
5
  "description": "Nexum SDK 扩展公共类型协议",
6
6
  "license": "UNLICENSED",
@@ -15,7 +15,7 @@
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
  ".": {