@asterism-app/sdk 1.10.0 → 1.10.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.
@@ -8,6 +8,8 @@ Use a resource for something that belongs in a session and can be inspected or o
8
8
 
9
9
  The resource attaches when it becomes present in a session. Removal immediately ends discovery and cancels its managed tasks and model requests. Other owners' requests holding the resource can finish before its attachment lifetime ends and the instance is disposed. A hidden card does not imply that its backend instance should stop.
10
10
 
11
+ Provide `disposalWarnings()` when the resource backend owns live instances whose termination needs confirmation. Enumerate only those live instances, returning their resource references and warning messages. The host selects the affected resources for removal, archival, or application exit and supplies their current titles. Saved resource data alone does not need an exit warning; do not restore instances to check them. Warning discovery does not perform cleanup, which remains owned by lifetimes.
12
+
11
13
  Creation supplies initial state. Actions change the object through typed application or plugin operations. Views present the resulting state.
12
14
 
13
15
  Implement `inspect` to expose model-facing resource state. The host includes this state in resource listings and individual inspection results; individual inspection also supplies available tool definitions. Link notifications contain identity only. Return the information needed to recognize and use the resource without relying on the host to interpret its saved state.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asterism-app/sdk",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "Public contracts and host capabilities for Asterism plugins",
5
5
  "license": "MIT",
6
6
  "author": "Chien Zhang",
@@ -12,7 +12,7 @@ import type { EventContract, PluginEvents } from "./events.ts";
12
12
  import type { ToolCompletion, ToolInvocationInfo, ToolModelOutput } from "./tool-result.ts";
13
13
  import type { PluginConfig, PluginLogger, PluginSecrets, PluginTasks } from "./runtime.ts";
14
14
  import type { ModelServices } from "./models.ts";
15
- import type { ResourceSnapshot, SessionSnapshot, SessionDirectory } from "./workspace.ts";
15
+ import type { ResourceRef, ResourceSnapshot, SessionSnapshot, SessionDirectory } from "./workspace.ts";
16
16
  import type { ActionContract, CreationContract } from "./commands.ts";
17
17
  import type { ObjectReader, ObjectExecutor, SessionExecutor } from "./objects.ts";
18
18
  import type { ContentReader, ContentScope } from "./content-runtime.ts";
@@ -116,6 +116,11 @@ export interface ActionContribution {
116
116
  prepare?(input: Json, context: ActionPreparation): Preparation | Promise<Preparation>;
117
117
  execute(input: Json, object: ObjectExecutor, signal: AbortSignal): Promise<void>;
118
118
  }
119
+ /** A live runtime instance whose termination needs user confirmation. */
120
+ export interface ResourceDisposalWarning {
121
+ readonly resource: ResourceRef;
122
+ readonly warning: UiText;
123
+ }
119
124
  export interface ResourceContribution {
120
125
  readonly resource: ResourceContract;
121
126
  /** Geometry declarations for backend placement, shared with ResourceDescription and cardRenderer. */
@@ -136,8 +141,11 @@ export interface ResourceContribution {
136
141
  context?(resource: ResourceSnapshot, object: ObjectReader): Promise<ContextFile[]>;
137
142
  /** Resolve a file address against this resource at consumption time; consumers need no link or registration of the reference. */
138
143
  openFile?(resource: ResourceSnapshot, locator: Json, context: { object: ObjectReader; signal: AbortSignal }): AsyncIterable<Uint8Array>;
139
- /** Explanation presented to users before ending the current instance; does not block backend removal or wait for external cleanup. */
140
- disposalWarning?(resource: ResourceSnapshot, object: ObjectReader): UiText | null;
144
+ /**
145
+ * Enumerate warnings from this backend's live instances without restoring saved resources.
146
+ * The host selects affected identities and resolves their current titles. Does not perform cleanup.
147
+ */
148
+ disposalWarnings?(): readonly ResourceDisposalWarning[];
141
149
  /**
142
150
  * Called synchronously when an object enters the current set through startup, creation, restoration, or rewinding.
143
151
  * Removal ends discovery and cancels owned tasks/model requests immediately; attachment lifetime cleanup follows captured request holds.
@@ -48,7 +48,7 @@ export function implementResource<S extends Json, V extends Json>(
48
48
  inspect(data: NoInfer<S>, object: ObjectReader): Promise<Json>;
49
49
  context?(data: NoInfer<S>, object: ObjectReader): Promise<ContextFile[]>;
50
50
  openFile?(data: NoInfer<S>, locator: Json, context: { object: ObjectReader; signal: AbortSignal }): AsyncIterable<Uint8Array>;
51
- disposalWarning?(data: NoInfer<S>, object: ObjectReader): import("./i18n.ts").UiText | null;
51
+ disposalWarnings?: ResourceContribution["disposalWarnings"];
52
52
  /** Called when an object enters the current set; external instances owned exclusively by the object register cleanup with lifetime. */
53
53
  attach?(data: NoInfer<S>, object: ObjectReader, lifetime: Lifetime): void;
54
54
  },
@@ -62,7 +62,7 @@ export function implementResource<S extends Json, V extends Json>(
62
62
  context: async (snapshot, object) => definition.context?.(parse(resource.stateSchema, snapshot.data, "resource"), object) ?? [],
63
63
  ...(openFile ? { openFile: (snapshot: ResourceSnapshot, locator: Json, context: { object: ObjectReader; signal: AbortSignal }) =>
64
64
  openFile(parse(resource.stateSchema, snapshot.data, "resource"), locator, context) } : {}),
65
- disposalWarning: (snapshot, object) => definition.disposalWarning?.(parse(resource.stateSchema, snapshot.data, "resource"), object) ?? null,
65
+ disposalWarnings: definition.disposalWarnings,
66
66
  ...(attach ? { attach: (snapshot: Parameters<NonNullable<ResourceContribution["attach"]>>[0], object: ObjectReader, lifetime: Lifetime) =>
67
67
  attach(parse(resource.stateSchema, snapshot.data, "resource"), object, lifetime) } : {}),
68
68
  };
@@ -17,7 +17,7 @@ export interface InteractiveTerminal {
17
17
  cursor: { x: number; y: number }; offset: number; nextOffset: number; truncated: boolean;
18
18
  }>;
19
19
  image(): Promise<TerminalImage>;
20
- waitIdle(timeout: number, signal: AbortSignal): Promise<TerminalStatus & { reason: string; elapsedMs: number }>;
20
+ waitIdle(timeout: number | undefined, signal: AbortSignal): Promise<TerminalStatus & { reason: string; elapsedMs: number }>;
21
21
  }
22
22
  export interface TerminalSessions {
23
23
  create(config: TerminalConfig, events: { failed(error: unknown): void; log(message: string, error: unknown): void }): InteractiveTerminal;