@asterism-app/sdk 1.12.0 → 1.13.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.
@@ -24,6 +24,8 @@ A resource owns the meaning of its locations and the surfaces used to display th
24
24
 
25
25
  A reference names something; it is not an access grant or proof of current availability. Resolve it when followed and report the actual result. Keep navigation initiated by a user distinct from a model request's captured authorization scope.
26
26
 
27
+ A source's location actions express what users can do with the original material independently of its preview format. Declare those actions with the resource rather than teaching shared chips and viewers to recognize particular resource kinds. Resolve the actual target when an action runs: an earlier preview is not proof of current availability. An internal preview, a system application, and a file-manager reveal can reach the same source without exporting a copy or treating an unsaved editor draft as saved content.
28
+
27
29
  Opening a file should preserve its meaning as file content. Text inside it does not become another application interaction contract merely because the viewer can recognize a link-like string.
28
30
 
29
31
  ## Keep transfers with the right owner
@@ -24,7 +24,7 @@ const usage: UsageProvider = {
24
24
  },
25
25
  };
26
26
  const preset: ModelProviderPreset = {
27
- id: "example-plan", name: "Example plan", billing: "subscription",
27
+ id: "example-plan", name: "Example", billing: "subscription",
28
28
  connection: { protocol: "openai-responses", baseUrl: "https://example.invalid/v1", auth: "api_key", compatibility: [],
29
29
  usage: usage.id, fixedFields: ["protocol", "baseUrl", "auth", "compatibility", "usage"] },
30
30
  sources: ["https://example.invalid/docs"], verifiedOn: "2026-10-20",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asterism-app/sdk",
3
- "version": "1.12.0",
3
+ "version": "1.13.1",
4
4
  "description": "Public contracts and host capabilities for Asterism plugins",
5
5
  "license": "MIT",
6
6
  "author": "Chien Zhang",
@@ -17,6 +17,7 @@ export interface ModelProviderConnection {
17
17
  }
18
18
  export interface ModelProviderPreset {
19
19
  id: string;
20
+ /** Provider or product brand; region, plan, billing, and protocol distinctions remain separate from the name. */
20
21
  name: string;
21
22
  billing: "usage" | "subscription" | "none";
22
23
  region?: UiText;
@@ -1,4 +1,6 @@
1
- import { createContext, useContext } from "react";
1
+ import { createContext, useContext, type ReactNode } from "react";
2
+ import type { UiText } from "./i18n.ts";
3
+ import type { RendererApplicationServices } from "./renderer-services.ts";
2
4
  import type { ResourceRef } from "./workspace.ts";
3
5
  import type { RendererCalls } from "./renderer-calls.ts";
4
6
  import type { RendererIsland } from "./renderer-island.ts";
@@ -14,12 +16,29 @@ export interface RendererResourceOpenContext extends RendererResourceOpenOptions
14
16
 
15
17
  export type RendererResourceOpener = (location: string, context: RendererResourceOpenContext) => boolean | Promise<boolean>;
16
18
 
19
+ /** A user-invoked location action. IDs are stable within a resource type; "open" is the host's in-app action. */
20
+ export interface RendererResourceLocationAction {
21
+ readonly id: string;
22
+ readonly label: UiText;
23
+ readonly icon: ReactNode;
24
+ run(options?: RendererResourceOpenOptions): void | boolean | Promise<void | boolean>;
25
+ }
26
+
27
+ /** Resources declare available actions; each action resolves its target when invoked. */
28
+ export type RendererResourceLocationActions = (location: string, context: {
29
+ readonly resource: ResourceRef;
30
+ readonly calls: RendererCalls;
31
+ readonly application: RendererApplicationServices;
32
+ }) => readonly RendererResourceLocationAction[];
33
+
17
34
  /** Current identity and title of a present resource; kind selects its presentation through useRendererResources. */
18
35
  export interface RendererResourceIdentity { readonly ref: ResourceRef; readonly title: string }
19
36
 
20
37
  export interface RendererResourceNavigation {
21
38
  /** Read the resource's current identity and title at call time; null when the session or resource is absent. Other failures reject. */
22
39
  resolve(resource: Pick<ResourceRef, "sessionId" | "id">): Promise<RendererResourceIdentity | null>;
40
+ /** Resolve current presence and available location actions. The host supplies "open" when an in-app opener exists; resource actions retain their declared IDs. Lookup failures reject; action execution reports failures through the host. */
41
+ actions(resource: Pick<ResourceRef, "sessionId" | "id">, location: string): Promise<readonly RendererResourceLocationAction[]>;
23
42
  /** Resolve current presence without model-request authorization. Failures are shown by the host; a cancelled open returns false. */
24
43
  open(resource: Pick<ResourceRef, "sessionId" | "id">, location: string, options?: RendererResourceOpenOptions): Promise<boolean>;
25
44
  }
@@ -87,6 +87,8 @@ export interface RendererApplicationServices {
87
87
  preferences(pluginId: string): import("./renderer-creation.ts").RendererPreferences;
88
88
  pickDirectory(initialPath?: string): Promise<string | null>;
89
89
  openLocalFile(path: string): Promise<void>;
90
+ /** Select a local file in the system file manager; directory targets open in that manager. */
91
+ showLocalFile(path: string, directory: boolean): Promise<void>;
90
92
  readonly files: {
91
93
  open(ref: import("./files.ts").FileRef): AsyncIterable<Uint8Array>;
92
94
  /** Show the system Save As dialog, then consume the stream. Returns false when the user cancels. */
package/src/renderer.ts CHANGED
@@ -35,7 +35,7 @@ import type { EventSubscriber } from "./events.ts";
35
35
  import type { PluginCalls } from "./calls.ts";
36
36
  import type { RendererCalls } from "./renderer-calls.ts";
37
37
  import type { ChannelContract, ChannelEnd, ChannelValue } from "./channels.ts";
38
- import type { RendererResourceOpener } from "./renderer-resource-open.ts";
38
+ import type { RendererResourceOpener, RendererResourceLocationActions } from "./renderer-resource-open.ts";
39
39
 
40
40
  /** The frontend end of a channel: messages are delivered in order and buffered until a listener registers; closed resolves when either end terminates. */
41
41
  export interface RendererChannel<Up extends ChannelValue = ChannelValue, Down extends ChannelValue = ChannelValue> {
@@ -95,6 +95,8 @@ export interface ResourceDescription {
95
95
  card?: CardAppearance;
96
96
  /** Open an opaque location using this resource's own operation or content surface. */
97
97
  open?: RendererResourceOpener;
98
+ /** Additional user actions for a location, independent of its in-app preview format. The ID "open" is reserved for the host. */
99
+ actions?: RendererResourceLocationActions;
98
100
  }
99
101
  export interface CardView extends CardAppearance {
100
102
  body: ReactNode;