@asterism-app/sdk 2.3.0 → 2.5.0
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.
- package/README.md +3 -25
- package/docs/data-and-lifecycle.md +18 -40
- package/docs/getting-started.md +20 -28
- package/docs/manual.md +4 -10
- package/docs/resources-and-tools.md +15 -39
- package/docs/views-and-settings.md +3 -3
- package/docs/visual-language.md +14 -12
- package/examples/counter/package.json +1 -1
- package/examples/tool-renderer.ts +8 -4
- package/package.json +1 -1
- package/src/content-runtime.ts +2 -0
- package/src/model-catalog.ts +6 -1
- package/src/model-records.ts +7 -2
- package/src/models.ts +18 -11
- package/src/module-contract.ts +44 -12
- package/src/reference-urls.ts +13 -5
- package/src/renderer-content.ts +2 -0
- package/src/renderer-island.ts +9 -2
- package/src/renderer-resource-open.ts +6 -2
- package/src/renderer-services.ts +2 -2
- package/src/renderer-tools.ts +75 -22
- package/src/renderer-ui.ts +61 -0
- package/src/runtime-contracts.ts +22 -6
- package/src/runtime-resources.ts +43 -16
- package/src/runtime-tools.ts +20 -9
- package/src/tool-validation.ts +1 -1
- package/docs/minimal-plugin.md +0 -33
- package/docs/project-structure.md +0 -37
package/README.md
CHANGED
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
# Asterism SDK
|
|
2
2
|
|
|
3
|
-
The SDK is the
|
|
3
|
+
The SDK is the public hosting boundary between Asterism and plugins. Plugins own the meaning of their resources and workflows. Agent conversation and other paradigm-specific work belong to the plugin that implements them.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Start with [Design and deliver a plugin](docs/getting-started.md) for design choices and validation. Resolve interfaces from the public source and types for the target release, not from the manual. The Manual includes the counter example as a source prototype to inspect, not as an API reference.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Keep backend work and frontend presentation separate while making each capability's ownership understandable. The host composes contributions; it does not infer domain behavior from a plugin's private state.
|
|
10
|
-
|
|
11
|
-
## Develop for the target application
|
|
12
|
-
|
|
13
|
-
Use a compatible SDK version for development and treat the running application as the runtime provider. Development dependencies supply declarations; peer dependencies express the host-provided relationship. Installing a newer SDK does not upgrade the application's capabilities.
|
|
14
|
-
|
|
15
|
-
Validate both contract agreement and actual integration. Type checking cannot establish that a distributed plugin includes all required assets, works in the intended application, or releases the work it owns.
|
|
16
|
-
|
|
17
|
-
## Deliver an explicit build
|
|
18
|
-
|
|
19
|
-
Use `@asterism-app/plugin-build` as an authoring dependency and run its `asterism-plugin-build` CLI explicitly. Source entries belong under `asterism.build`; the build writes the loaded artifact into `dist`. Build, add the package directory, and restart. Later source changes require another build and restart, not a different plugin mode.
|
|
20
|
-
|
|
21
|
-
Declare host packages and other plugins' public packages as peer dependencies; the artifact keeps those imports external so they bind to the running instances. Ordinary dependencies stay private, and the backend loads them from the installed package.
|
|
22
|
-
|
|
23
|
-
Build before packing and inspect the tarball. Typechecking and a successful build do not establish installed-application or platform compatibility.
|
|
24
|
-
|
|
25
|
-
## Keep authoring material purposeful
|
|
26
|
-
|
|
27
|
-
The package includes prose guides and maintained source examples. Guides explain mental models, ownership, integration choices, and working principles; public declarations and examples carry concrete interfaces and assembly. The complete counter package provides a small design to adapt, not a required architecture for every plugin.
|
|
28
|
-
|
|
29
|
-
These materials support software use and plugin development on demand. Runtime tool descriptions, guidelines, and schemas own tool invocation knowledge independently of the manual.
|
|
7
|
+
For renderer plugins, [Fit plugin views into the workbench](docs/visual-language.md) distinguishes workbench integration from the choice of shared, third-party, or custom controls.
|
|
@@ -1,61 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Own data and work over time
|
|
2
2
|
|
|
3
|
-
Choose storage from
|
|
3
|
+
Choose storage and lifetime from what a value means. Current values, historical facts, preserved bytes, and running processes answer different questions and have different owners.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Choose what to preserve
|
|
6
6
|
|
|
7
|
-
Current data answers what is true now. History explains what happened.
|
|
7
|
+
Current data answers what is true now. History explains what happened. A counter might keep its latest value and record each increment; a document editor might promise a restorable body at each revision. Make restoration an explicit domain operation rather than promising it just because something is recorded.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Keep plugin-wide data with the plugin and transient interface choices with the view. Keep business state separate from host identity and presentation. A domain field called “title” need not be the card title, and a domain identifier need not be the host resource identity.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Treat encoding as a domain boundary
|
|
14
|
-
|
|
15
|
-
Use a codec when the value plugin code works with differs from its stored representation. Keep conversion semantics with that declaration rather than scattering normalization through readers and writers. A one-way input transformation and a reversible storage conversion solve different problems.
|
|
16
|
-
|
|
17
|
-
Check meaningful round trips for custom conversions. In particular, reading an old representation and writing a new one should preserve the domain value even when their JSON differs. Compatibility decoding can make an old fact readable without rewriting what was originally recorded.
|
|
18
|
-
|
|
19
|
-
Separate host identity and presentation from business state. A domain field named “title” need not be the card title, and a domain identifier need not be the host resource identity. Conflating them makes renaming and reuse surprising.
|
|
20
|
-
|
|
21
|
-
## Decide what a template can reuse
|
|
22
|
-
|
|
23
|
-
A data-copy template is appropriate when selected saved values remain meaningful under new host identities. A note can reuse its body; an Agent can reuse configuration without carrying pending work into a new session.
|
|
24
|
-
|
|
25
|
-
Treat copying an address differently from cloning what it addresses. A resource that depends on an external account, embedded object identities, or private files may need an explicit domain-specific cloning operation instead of a data-copy template. Such an operation can explain what will be shared, copied, or reconnected.
|
|
26
|
-
|
|
27
|
-
Choose titles according to the same distinction. Preserving a descriptive source title can help users recognize a reusable setup; generating a title can make sense when each instance represents new work.
|
|
11
|
+
A template copies setup that remains meaningful under new identities. It may reuse a note's body or an Agent's configuration, not their running work. Decide which saved values should carry over and what a copied address shares rather than clones. Decide whether a new object needs the original title or one derived from the new task.
|
|
28
12
|
|
|
29
13
|
## Commit facts, then observe them
|
|
30
14
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Use a pending operation record when consumers need to know about work before its result exists. Its identity represents one operation from published input to final outcome. Keep progress transient unless it has lasting domain meaning, and assign responsibility for ending abandoned work to the owner that started it.
|
|
15
|
+
Finish asynchronous preparation before committing related facts together. If an operation must be visible while pending, give it one durable identity from submission to final outcome. Keep progress transient unless it has lasting domain meaning.
|
|
34
16
|
|
|
35
|
-
A snapshot fixes the evidence being read
|
|
17
|
+
A snapshot fixes the evidence being read, not the destination of future writes. Reuse it for related queries that need a common basis. Notifications are prompts to observe: read current state for a current-state consumer, and use durable facts if missing an event during downtime changes the result.
|
|
36
18
|
|
|
37
|
-
|
|
19
|
+
Read another domain's history through its original public contract. Unreadable evidence is not absent evidence. Restoring an object's current presence does not mean it was just created; observe committed creation facts for historical reactions and attachment lifetimes for present work.
|
|
38
20
|
|
|
39
|
-
##
|
|
21
|
+
## Evolve a saved format without changing the fact
|
|
40
22
|
|
|
41
|
-
|
|
23
|
+
Use a codec when the stored representation differs from what domain code should see. Check that round trips preserve meaning. When an older encoding is still straightforward to read, compatible decoding can leave the saved bytes alone. When an incompatible representation must be converted together before the plugin runs, declare a startup migration instead of scattering repairs through readers and service startup. If the meaning changes rather than just the encoding, give the new fact a new contract.
|
|
42
24
|
|
|
43
|
-
|
|
25
|
+
Version private formats independently of session history. A record group is for owned timeline contracts that must evolve together. Keep its identity and membership stable; do not move existing contracts between groups or assume a changed member inherits the correct version. Convert only the recorded data, using rules tied to the old format rather than today's business defaults. Preserve source, position, and the content the fact retains. Migration changes the persisted format; readers remain responsible for interpreting and validating the content. Do not revise past decisions, recreate resources, or repeat external effects.
|
|
44
26
|
|
|
45
|
-
|
|
27
|
+
Test the conversion with a real old-format fixture and an expected encoding. Include records on alternate paths and retained content when relevant. Check that a second startup leaves the prepared data unchanged and that an interrupted or failed upgrade has a recovery path. Do not assume independent stores upgrade as one transaction; the plugin may remain unavailable while a previously prepared store is already on the new version.
|
|
46
28
|
|
|
47
|
-
##
|
|
29
|
+
## Separate addresses from preserved bytes
|
|
48
30
|
|
|
49
|
-
|
|
31
|
+
Use a file reference when the consumer should decide whether and when to read current external content. Use retained content when a record or export must still mean the same bytes later. Passing an address does not preserve a version or confer access.
|
|
50
32
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Content identifiers alone are not ownership or access. Preserve retained references in the saved encoding, and transfer ownership before closing temporary content scopes. A reference synthesized only while decoding cannot preserve bytes that were never retained.
|
|
33
|
+
Keep retained references in the saved encoding and transfer ownership before closing temporary scopes. A reference synthesized only when reading cannot preserve bytes that were never retained.
|
|
54
34
|
|
|
55
35
|
## End work with its owner
|
|
56
36
|
|
|
57
|
-
Bind shared services to the plugin
|
|
58
|
-
|
|
59
|
-
Use timeline activity tracking for work whose writes depend on the current history position. An external service may need to stop when its resource disappears without otherwise preventing history navigation. Choose based on that dependency, not merely on whether the operation is asynchronous.
|
|
37
|
+
Bind shared services to the plugin and object-owned work to the resource. Register cleanup at the point of ownership, pass cancellation into the I/O it controls, and wait for actual completion before releasing dependencies.
|
|
60
38
|
|
|
61
|
-
|
|
39
|
+
Track timeline activity when work depends on a history position. A service may otherwise need to stop when its resource disappears without preventing history navigation. Choose based on that dependency, not simply because an operation is asynchronous.
|
package/docs/getting-started.md
CHANGED
|
@@ -1,41 +1,33 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Design and deliver a plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Start with one useful path from a user's intent to a domain result. Decide who owns the state, what changes it, and how the result becomes visible. Add more surfaces only when that path needs them. A plugin owns installation, identity, and lifetime; features can share that ownership without sharing every implementation detail.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Choose what to integrate with
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Extend an existing domain through its public contracts when that domain should still own the work. Own a resource when the capability has its own identity and lifetime. Own a paradigm only when you need to decide how work starts, how requests are assembled, and how execution is presented. A session does not require an Agent.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Keep shared declarations separate from backend work and frontend presentation. Organize each capability so its state transitions remain understandable together. Publish contracts when other plugins need their meaning, not to expose the provider's internal structure. Import the original declarations: a copy can match their types without sharing their runtime identity.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Resolve interfaces from the target release
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Use the Manual's SDK counter and built-in Agent examples to inspect a small plugin before writing one. Read them to see how responsibilities fit together; there is no need to run or install them to learn from them.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
For implementation, start at the target release's public SDK or domain package exports, follow the types to their declarations, and trace a similar shipped capability and its tests in the application source. Check which parts are public before reusing them. Use the builder's source and CLI help for build configuration.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Develop against the packages for the application release you intend to support. The application and enabled providers supply shared packages at runtime; adding a development dependency does not install or upgrade the provider. Treat host-supplied packages as peer dependencies and keep ordinary private libraries with the plugin.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Validate what users will load
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
The application loads a completed artifact, even when using a local checkout. Build separately, restart to activate it, and test the package outside the development workspace so dependency hoisting cannot hide missing declarations. Rebuild and restart after changing source; replacing files under a running graph can break a later lazy load.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Follow one action from its initiating surface to the committed result and back to the user. Check rejection, cancellation, reopening saved work, and cleanup with the owner gone. Type checking tests agreement with declarations; loading the delivered artifact tests the provider, dependencies, and files users actually receive. Use both.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
## Find the next design decision
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Check the normal path, meaningful invalid input, visible failures, and cleanup when the owning resource or plugin ends. Reopen saved work to distinguish durable state from accidental reliance on a live instance.
|
|
36
|
-
|
|
37
|
-
## Verify what users receive
|
|
38
|
-
|
|
39
|
-
Test the distributed package in an installed application, not only the source checkout. Build before packing, and inspect the actual tarball. Use a clean release checkout. Include the completed output, root metadata, documentation, and translation catalogs, and declare every package the plugin imports at runtime in `dependencies` or `peerDependencies`. Installation must not need to compile plugin source. Files available only on the author's machine should not be necessary.
|
|
40
|
-
|
|
41
|
-
Update public package versions intentionally and repeat the relevant integration checks. A compatible editor view is useful evidence, but the application remains the provider of runtime capabilities.
|
|
27
|
+
| If you need to decide… | Read |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| What an Agent can discover, call, and learn from an operation | [Resources and tools](resources-and-tools.md) |
|
|
30
|
+
| What to persist, migrate, or release | [Data and lifecycle](data-and-lifecycle.md) |
|
|
31
|
+
| How a workflow starts or receives external events | [Session entries](session-entries.md), [messaging](messaging.md) |
|
|
32
|
+
| What a view owns and how it fits the workbench | [Views and settings](views-and-settings.md), [visual language](visual-language.md) |
|
|
33
|
+
| What belongs in a plugin's own manual | [Plugin documentation](manual.md) |
|
package/docs/manual.md
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
# Publish useful plugin documentation
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Choose what to publish
|
|
6
|
-
|
|
7
|
-
Expose directories intended for users learning the software or authors developing an integration. Include that material in the distributed package. Internal fixtures, private working notes, and credentials have different audiences and belong outside the published material.
|
|
3
|
+
Publish design and usage topics through the Manual resource so an Agent can find the reasoning it needs without loading the whole handbook. Include small source examples when reading the prototype makes an integration easier to grasp. Keep test fixtures with the code they exercise and leave exact interfaces to the public declarations.
|
|
8
4
|
|
|
9
5
|
Keep documentation with the domain that owns its meaning. Generic hosting concepts belong to the SDK; a plugin's behavior and extension rationale belong to that plugin or its public API package. A separate public API library can own its authoring material without becoming another executable plugin.
|
|
10
6
|
|
|
11
7
|
## Explain decisions that declarations cannot
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
An example is worth discussing when the explanation helps an author adapt it. Explain why a service is shared, why a record is durable, or why a view does not own a task. Let the example's source carry its exact syntax.
|
|
9
|
+
Explain decisions an Agent cannot recover from declarations: why a service is shared, when a record should be durable, or why a view does not own a task. For exact interfaces and concrete assembly, direct development to the target SDK, application source, and tests.
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
Group independently readable articles by the reader's decisions. When a mechanism changes those decisions, revise their existing topic or remove outdated guidance rather than creating a page for the mechanism.
|
|
18
12
|
|
|
19
13
|
## Document shortcuts where they work
|
|
20
14
|
|
|
21
15
|
If your plugin provides keyboard shortcuts, publish a **Keyboard shortcuts** topic or section in its own manual. Group shortcuts by view or dialog. Say where focus must be, what the shortcut does, and which keys differ by platform. Include a command or button alternative when it helps users find the action.
|
|
22
16
|
|
|
23
|
-
The application manual covers shortcuts owned by the host. A plugin topic covers the plugin’s shortcuts, including any context that determines when they are available.
|
|
17
|
+
The application manual covers shortcuts owned by the host. A plugin topic covers the plugin’s shortcuts, including any context that determines when they are available. Include it in the shipped manual.
|
|
24
18
|
|
|
25
19
|
## Keep runtime guidance with tools
|
|
26
20
|
|
|
@@ -1,53 +1,29 @@
|
|
|
1
|
-
# Design resources and
|
|
1
|
+
# Design resources and tool calls
|
|
2
2
|
|
|
3
|
-
A resource
|
|
3
|
+
A resource is an object with identity and lifetime. A tool is an operation a model can choose. Keep them independent so the same operation can work across different objects without making them share a domain model.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Decide which capability should be callable
|
|
6
6
|
|
|
7
|
-
Use a resource
|
|
7
|
+
Use a resource when the work has a recognizable subject with its own state or lifetime. Keep model-facing state with that resource; it should let a model recognize the subject and its relevant condition. A card presents the object, but hiding it neither ends its work nor revokes links.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Expose a tool when a model needs to choose and perform the operation. When application code already knows what to do, use the owning domain service or typed action rather than routing through a model. Share the same business logic behind these surfaces. Choose a resource tool for work on a linked object; choose a top-level tool for work on the execution context or shared lifecycle that has no such subject.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Design the call around intent
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Reuse a public tool contract when its meaning and shared input are the same across resources. A structured read, for example, can express the same operation while each implementation decides how to address its own content and views. A different effect or meaning deserves a different contract, even if it uses similar code. Name the operation for what the caller is asking it to do.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Choose structured input when the model must supply independent choices or when a distinct target makes resource-specific selection clearer. Choose freeform when the whole input belongs to one text syntax, and validate that syntax at the operation boundary. An operation that takes text and independent options can still be structured. Keep provider-specific encoding out of the domain contract.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Design for discovery: explain the purpose, required context, result, and how its outputs can be used next in the tool's own guidance and schemas. Explain the absence of a result or an uncertain effect where it changes the caller's next decision. A short write receipt should report what changed, not repeat the input or the display diff. The model should be able to call the tool without having read this manual.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Keep execution with its owner
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Treat links, tool discovery, and permission to execute as separate facts. A visible card or known address is not authority; a reverse link is independent. Bind access and configuration at the request boundary, but read ordinary mutable content when handling the operation.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Order operations according to their dependencies rather than whether they read or write. Require interaction only if a user's response is necessary to complete the work. Keep progress separate from durable results, and distinguish rejection, cancellation, partial completion, and uncertain effects. Stopping a caller does not undo completed effects.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
## Compose and verify calls through their actual surface
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Use session-bound execution when a model should work through the session's links and real resources. Use direct model execution when the caller supplies its own messages and executable tools without a workbench object. The caller owns conversation policy, recording, and retry decisions; session access alone does not make work depend on the current history position.
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Put invocation knowledge in the contract
|
|
32
|
-
|
|
33
|
-
Tool descriptions, guidelines, and schemas must support use independently of the manual. Explain purpose, how outputs relate to later inputs, input meaning, result interpretation, and execution boundaries in the owning contract.
|
|
34
|
-
|
|
35
|
-
Use examples to clarify data flow without prescribing a workflow. Describe an operation's own use of a file reference rather than assuming which resource produced it or which consumer follows it. Distinguish failure, cancellation, partial output, and uncertain effects when those differences affect what a caller can conclude.
|
|
36
|
-
|
|
37
|
-
Choose scheduling according to ordering requirements, not simply whether an operation reads or writes. Require interaction only when completion depends on a user response; showing progress alone does not make backend work interactive.
|
|
38
|
-
|
|
39
|
-
## Compose model execution deliberately
|
|
40
|
-
|
|
41
|
-
Session-bound model execution is useful when a request should act through a resource's links and real session. Direct model execution suits work whose messages and executable tools are supplied by the caller without a workbench object. Choose based on the access and history relationship, not on a presumed requirement to create an Agent.
|
|
42
|
-
|
|
43
|
-
Capture configuration and authorization at the request boundary. Read ordinary mutable content when handling an operation. For a resource addressing a selected network, this keeps the meaning of its addresses stable through the tool batch without pretending the network's content is frozen.
|
|
44
|
-
|
|
45
|
-
The caller owns conversation policy, historical recording, and retry decisions. Keep transient progress distinct from durable operation results. A generation failure does not necessarily mean that every earlier tool effect failed or that repeating the request is safe.
|
|
46
|
-
|
|
47
|
-
Resource access and timeline activity are also separate. Work that depends on a history position needs the appropriate activity scope; merely holding access to a resource does not establish that dependency. Temporary conversations need explicit ownership of attachments that must survive into later requests.
|
|
48
|
-
|
|
49
|
-
## Separate services from their interfaces
|
|
50
|
-
|
|
51
|
-
A backend capability does not automatically need a resource card or a model tool. Typed calls, events, and sustained channels serve different interaction needs; choose them according to whether the consumer requests a result, observes a change, or maintains a live connection.
|
|
52
|
-
|
|
53
|
-
For example, a one-shot shell process and a persistent terminal need different owners. Cancelling a command concerns that process; closing one terminal view need not end a shell shared with other views. Host services supply the execution mechanics, while the plugin chooses the domain object, presentation, and callable interface.
|
|
29
|
+
Start at the target SDK's public declarations and follow a similar tool from registration to dispatch and result projection in the application source. Verify what discovery actually shows and run the operation through its intended caller, not just its handler. Check invalid input, inaccessible targets where relevant, and whether the result gives the caller enough evidence to continue without guessing or repeating an effect.
|
|
@@ -10,11 +10,11 @@ Use host presentation for containment and navigation. Keep the plugin's domain c
|
|
|
10
10
|
|
|
11
11
|
## Carry a tool view from input to result
|
|
12
12
|
|
|
13
|
-
A tool title should identify the work before it produces output. Give long questions, commands, and other unbounded inputs a short, single-line excerpt.
|
|
13
|
+
A tool title should identify the work before it produces output. Give long questions, commands, and other unbounded inputs a short, single-line excerpt. Let the excerpt yield to a distinct status label and make the complete input available in the expanded view.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
While the model generates input, a preview can follow the tail of the draft. Treat an incomplete structured preview as display data, not validated arguments. For a freeform view, preserve whitespace and distinguish empty text from missing input. Once the tool begins, its input is stable: put the context and controls that users still need outside any live-output viewport. A tool that only needs to show status or ask for input does not need a streaming region.
|
|
16
16
|
|
|
17
|
-
If a tool emits a growing report or log,
|
|
17
|
+
If a tool emits a growing report or log, bound that section’s height so updates cannot push its context away. Follow new content at the end, but let readers move away without losing their place. When the operation settles, keep the input and report in the same places and update the status or add outcome details in place. The renderer owns these choices; a streaming declaration tells the host when a body is available for automatic disclosure, not how to lay it out or scroll it.
|
|
18
18
|
|
|
19
19
|
## Give expanded views a meaningful identity
|
|
20
20
|
|
package/docs/visual-language.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Fit plugin views into the workbench
|
|
2
2
|
|
|
3
|
-
A plugin's views appear beside the host's own and other plugins' views.
|
|
3
|
+
A plugin's views appear beside the host's own and other plugins' views. The SDK provides Asterism-specific ways to register tool and card views, open islands, and use workbench navigation. Within those views, you choose the controls.
|
|
4
|
+
|
|
5
|
+
Choose controls that meet your view's requirements. You can use a third-party library, write your own controls, or use the SDK's shared controls. When an SDK control fits and you want the same appearance and interaction as the workbench, it saves you that work. If it doesn't fit, use another control without cutting features to match the SDK. You can mix these choices in the same view.
|
|
4
6
|
|
|
5
7
|
## Start from the host's containers
|
|
6
8
|
|
|
@@ -17,41 +19,41 @@ Inside a sheet, a region reads as a region because its tone differs, not because
|
|
|
17
19
|
- **Group**: rows, fields, and repeated items that belong together recede into a group in the shell tone, with hairlines between rows.
|
|
18
20
|
- **Floating**: menus, popovers, tooltips, hover cards, and dialogs lift above content and keep their outer edge.
|
|
19
21
|
|
|
20
|
-
A plugin that needs a group
|
|
22
|
+
A plugin that needs a group uses the shell tone rather than adding a border; the shared settings layout and list controls already follow this rule. Inside something that is already recessed, such as a tool's output in the conversation, a sub-panel rises back to the card tone instead of adding an outline. When two areas are already separated by tone, adding a border makes the view feel heavier and louder than the rest of the application.
|
|
21
23
|
|
|
22
24
|
## Use lines only when they mean something
|
|
23
25
|
|
|
24
26
|
Users learn that a line in Asterism tells them something: where focus is, what is selected, where a drop will land, or the state of a piece of work. A moving dashed outline means content is still forming, a still dashed outline means it ended incomplete, and a red line means the request that produced it failed. Hairlines between rows are the one structural line.
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Tool views receive their state outline from the host's process block. When showing status within your own content, pair color with an icon or label rather than relying on color alone.
|
|
27
29
|
|
|
28
30
|
## Let motion explain a change
|
|
29
31
|
|
|
30
32
|
Motion in the workbench answers a question for the reader: where did this come from, where did it go, or what changed? Selection indicators travel to the new item, deeper pages enter from the side and leave the way they came, arriving content fades in while leaving content clears quickly, lists fold their height as items join or leave, and values animate only when they change.
|
|
31
33
|
|
|
32
|
-
Plugin views
|
|
34
|
+
Plugin views should use the same motion cues and timing. Shared controls already carry their own motion; a segmented toggle's indicator, for example, slides without any plugin code. Avoid motion that decorates a static state, replays when an item merely scrolls into view, or competes with a list's own scrolling. Respect reduced motion in custom transitions as well.
|
|
33
35
|
|
|
34
36
|
## Choose controls by the kind of choice
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
Use the same interaction for the same kind of choice, whichever library supplies the controls:
|
|
37
39
|
|
|
38
40
|
- A single choice among a few short options is a segmented toggle group.
|
|
39
41
|
- An immediate on/off setting is a switch; a choice inside a form or a multi-selection is a checkbox; an explained single choice is a radio group.
|
|
40
|
-
- A choice among many options, or one that needs search, uses
|
|
41
|
-
- Icon-only actions
|
|
42
|
+
- A choice among many options, or one that needs search, uses a searchable picker in a popover.
|
|
43
|
+
- Icon-only actions have an accessible label and a tooltip.
|
|
42
44
|
- A short name or explanation on hover is a tooltip; a preview read while hovering is a hover card; content the user opens on purpose, scrolls, or acts on is a popover behind a button.
|
|
43
45
|
- Button variants carry roles: one default button for the primary action in a region, outline for supporting actions, ghost for compact and row actions, destructive for irreversible confirmation.
|
|
44
46
|
|
|
45
|
-
Tooltips share the popover tone
|
|
47
|
+
Tooltips share the popover tone. Keep their delay, placement, and width consistent. If a tooltip explains why an action is unavailable, make the explanation reachable even when the control is disabled.
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
## Use shared readers when they fit
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
The host supplies optional presentation controls through the SDK renderer. Tool titles can use `ToolHeader` with a subject, summary, and metadata. `ToolResourceSubject` puts the resource recorded with the call in the subject slot, and `HeaderExcerpt` shortens long inputs without truncating the operation name. `ToolScrollArea` provides a default height for settled results; `StreamingScrollArea` follows growing content. A view can use its own layout when those defaults do not fit.
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
`Diff` renders a unified diff of one file. Set wrapping or word-level change highlighting as needed, and turn line numbers off when hunk positions are not real file positions. The view owns its toolbar, preferences, and scroll layout. A plugin can also use its own diff viewer or other controls without changing how it connects to islands, cards, or tool views.
|
|
52
54
|
|
|
53
55
|
## Keep custom styling local
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
For third-party or custom controls, use the workbench's semantic color tokens and type roles when you want the view to follow the user's theme in both color schemes. CSS Modules keep plugin styles local, while global styles share the document cascade with the host and every other plugin. Avoid global selectors that would restyle shared controls or another plugin's views.
|
|
56
58
|
|
|
57
59
|
Check a view in light and dark modes, at each density, and with reduced motion before release. A typecheck cannot tell whether a view belongs in the workbench; looking at it beside the host's own views can.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createElement } from "react";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { defineData, type Json } from "@asterism-app/sdk/contracts";
|
|
5
|
-
import { HeaderExcerpt, StreamingScrollArea, toolRenderer, type ToolRenderProps } from "@asterism-app/sdk/renderer";
|
|
5
|
+
import { HeaderExcerpt, StreamingScrollArea, ToolHeader, ToolResourceSubject, toolRenderer, type ToolRenderProps } from "@asterism-app/sdk/renderer";
|
|
6
6
|
|
|
7
7
|
const Result = defineData("example.writer/write", z.object({ written: z.number() }));
|
|
8
8
|
const targetSchema = z.object({ path: z.string() });
|
|
@@ -38,10 +38,14 @@ export const writerView = toolRenderer({ ...Result, targetSchema, tool: { argsSc
|
|
|
38
38
|
const Report = defineData("example.writer/report", z.object({ text: z.string() }));
|
|
39
39
|
const reportArgs = z.object({ question: z.string() });
|
|
40
40
|
type ReportProps = ToolRenderProps<z.infer<typeof Report.schema>, Json, z.infer<typeof reportArgs>>;
|
|
41
|
-
function ReportHeader({ args }: ReportProps) {
|
|
41
|
+
function ReportHeader({ args, invocation }: ReportProps) {
|
|
42
42
|
const question = args !== null && typeof args === "object" && !Array.isArray(args) && typeof args.question === "string" ? args.question : "";
|
|
43
|
-
// The excerpt belongs in
|
|
44
|
-
return createElement(
|
|
43
|
+
// The excerpt belongs in the shrinkable summary slot, not in a tooltip containing the complete question.
|
|
44
|
+
return createElement(ToolHeader, {
|
|
45
|
+
label: "Report",
|
|
46
|
+
subject: invocation.resource && createElement(ToolResourceSubject, { resource: invocation.resource }),
|
|
47
|
+
summary: createElement(HeaderExcerpt, { text: question }),
|
|
48
|
+
});
|
|
45
49
|
}
|
|
46
50
|
function ReportBody(props: ReportProps) {
|
|
47
51
|
if (props.phase === "input") return null;
|
package/package.json
CHANGED
package/src/content-runtime.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Json } from "./json.ts";
|
|
|
3
3
|
|
|
4
4
|
/** Read complete content or a byte range; open streams the selected bytes in chunks. */
|
|
5
5
|
export interface ContentReader {
|
|
6
|
+
/** Validated byte length when the backing store exposes metadata without opening the stream. */
|
|
7
|
+
size?(ref: ContentRef): number;
|
|
6
8
|
read(ref: ContentRef, range?: ContentRange): Promise<Uint8Array>;
|
|
7
9
|
open(ref: ContentRef, range?: ContentRange): AsyncIterable<Uint8Array>;
|
|
8
10
|
}
|
package/src/model-catalog.ts
CHANGED
|
@@ -3,11 +3,16 @@ import { defineData } from "./presentation.ts";
|
|
|
3
3
|
import { modelCostSchema } from "./model-cost.ts";
|
|
4
4
|
import { thinkingSchema } from "./model-selection.ts";
|
|
5
5
|
|
|
6
|
+
export const modelMediaModalities = ["image", "audio", "video", "document"] as const;
|
|
7
|
+
export const modelMediaModalitySchema = z.enum(modelMediaModalities);
|
|
8
|
+
export type ModelMediaModality = z.infer<typeof modelMediaModalitySchema>;
|
|
9
|
+
export const modelInputModalitiesSchema = z.array(modelMediaModalitySchema);
|
|
10
|
+
|
|
6
11
|
export const catalogModelSchema = z.object({
|
|
7
12
|
providerId: z.string(), modelId: z.string(), name: z.string(), enabled: z.boolean(),
|
|
8
13
|
contextWindow: z.number().nullable(), cost: modelCostSchema.nullable(),
|
|
9
14
|
generation: z.object({ maxOutputTokens: z.number().nullable() }),
|
|
10
|
-
capabilities: z.object({ reasoning: z.boolean(), tools: z.boolean(), thinkingLevels: z.array(thinkingSchema) }),
|
|
15
|
+
capabilities: z.object({ reasoning: z.boolean(), tools: z.boolean(), thinkingLevels: z.array(thinkingSchema), inputModalities: modelInputModalitiesSchema.optional() }),
|
|
11
16
|
});
|
|
12
17
|
/** Enabled model metadata available to runtime consumers; model is the complete provider/model expression. */
|
|
13
18
|
export const modelInfoSchema = catalogModelSchema.omit({ providerId: true, modelId: true, enabled: true }).extend({
|
package/src/model-records.ts
CHANGED
|
@@ -44,14 +44,19 @@ export function completionData<T extends Json>(completion: ModelCompletion | nul
|
|
|
44
44
|
const result = contract.schema.safeParse(structuredClone(extension.data));
|
|
45
45
|
return result.success ? result.data : null;
|
|
46
46
|
}
|
|
47
|
+
export const toolCallInputSchema = z.discriminatedUnion("kind", [
|
|
48
|
+
z.strictObject({ kind: z.literal("structured"), value: jsonSchema }),
|
|
49
|
+
z.strictObject({ kind: z.literal("freeform"), text: z.string() }),
|
|
50
|
+
]);
|
|
51
|
+
export const toolInputDraftSchema = z.strictObject({ kind: z.enum(["structured", "freeform"]), text: z.string() });
|
|
52
|
+
|
|
47
53
|
const block = { responseId: id, requestParentId: id.nullable(), ordinal: z.number().int().nonnegative(),
|
|
48
54
|
complete: z.boolean(), continuation: jsonSchema, source: modelSourceSchema, completion: modelCompletionSchema.nullable().optional(),
|
|
49
55
|
/** Block generation start and end times (millisecond timestamps); blocks finalized before generation ends have a null end time, and unrecorded times are omitted. See outcome for tool execution times. */
|
|
50
56
|
startedAt: z.number().nonnegative().optional(), endedAt: z.number().nonnegative().nullable().optional() };
|
|
51
57
|
/** Tool call block shape without the completion invariant, for contracts that store input and outcome separately. */
|
|
52
58
|
export const modelToolCallBlockSchema = z.strictObject({ ...block, kind: z.literal("toolcall"), callId: id, name: id,
|
|
53
|
-
|
|
54
|
-
argumentsText: z.string().nullable(), arguments: jsonSchema, outcome: toolOutcomeSchema.nullable(), invocation: toolInvocationSchema.optional() });
|
|
59
|
+
input: toolCallInputSchema.nullable(), draft: toolInputDraftSchema.nullable(), outcome: toolOutcomeSchema.nullable(), invocation: toolInvocationSchema.optional() });
|
|
55
60
|
export const modelBlockSchema = z.discriminatedUnion("kind", [
|
|
56
61
|
z.strictObject({ ...block, kind: z.literal("thinking"), text: z.string(), summary: z.string() }),
|
|
57
62
|
z.strictObject({ ...block, kind: z.literal("text"), text: z.string() }),
|