experimental-ash 0.47.0 → 0.49.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/CHANGELOG.md +36 -0
- package/dist/docs/internals/context.md +6 -12
- package/dist/docs/internals/hooks.md +15 -74
- package/dist/docs/internals/mechanical-invariants.md +3 -4
- package/dist/docs/internals/message-runtime.md +2 -3
- package/dist/docs/public/advanced/hooks.mdx +39 -76
- package/dist/docs/public/advanced/project-layout.md +1 -2
- package/dist/docs/public/advanced/typescript-api.md +1 -1
- package/dist/docs/public/channels/index.md +2 -2
- package/dist/docs/public/channels/slack.mdx +12 -17
- package/dist/docs/public/frontend/use-ash-agent.md +13 -17
- package/dist/src/channel/adapter.js +1 -1
- package/dist/src/channel/routes.d.ts +5 -7
- package/dist/src/channel/send.js +1 -1
- package/dist/src/channel/types.d.ts +3 -3
- package/dist/src/compiler/manifest.d.ts +1 -1
- package/dist/src/compiler/normalize-hook.d.ts +4 -4
- package/dist/src/context/build-dynamic-tools.d.ts +13 -0
- package/dist/src/context/build-dynamic-tools.js +1 -0
- package/dist/src/context/dynamic-instruction-lifecycle.d.ts +13 -13
- package/dist/src/context/dynamic-instruction-lifecycle.js +1 -1
- package/dist/src/context/dynamic-resolve-context.d.ts +12 -0
- package/dist/src/context/dynamic-resolve-context.js +1 -0
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.d.ts +4 -10
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/hook-lifecycle.d.ts +1 -46
- package/dist/src/context/hook-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +30 -32
- package/dist/src/context/keys.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +3 -4
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.d.ts +2 -3
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +24 -24
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/turn-workflow.d.ts +4 -5
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +1 -1
- package/dist/src/execution/workflow-steps.d.ts +1 -3
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/code-mode.js +1 -1
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/prompt-cache.d.ts +11 -1
- package/dist/src/harness/prompt-cache.js +1 -1
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/types.d.ts +4 -5
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/packages/ash-scaffold/src/channels.js +1 -1
- package/dist/src/public/channels/ash.js +2 -2
- package/dist/src/public/channels/discord/discordChannel.d.ts +1 -2
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/discord/inbound.d.ts +0 -3
- package/dist/src/public/channels/discord/inbound.js +1 -1
- package/dist/src/public/channels/discord/index.d.ts +1 -1
- package/dist/src/public/channels/discord/index.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +4 -13
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +3 -7
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/inbound.d.ts +0 -3
- package/dist/src/public/channels/teams/inbound.js +2 -2
- package/dist/src/public/channels/teams/index.d.ts +1 -1
- package/dist/src/public/channels/teams/index.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +1 -2
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/inbound.d.ts +0 -3
- package/dist/src/public/channels/telegram/inbound.js +1 -1
- package/dist/src/public/channels/telegram/index.d.ts +1 -1
- package/dist/src/public/channels/telegram/index.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +1 -2
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/inbound.d.ts +0 -3
- package/dist/src/public/channels/twilio/inbound.js +1 -1
- package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +6 -22
- package/dist/src/public/definitions/instructions.d.ts +7 -12
- package/dist/src/public/definitions/skill.js +1 -1
- package/dist/src/public/hooks/index.d.ts +4 -5
- package/dist/src/runtime/graph.d.ts +2 -3
- package/dist/src/runtime/hooks/registry.d.ts +5 -20
- package/dist/src/runtime/hooks/registry.js +1 -1
- package/dist/src/runtime/resolve-hook.d.ts +2 -2
- package/dist/src/runtime/resolve-hook.js +1 -1
- package/dist/src/runtime/types.d.ts +3 -9
- package/dist/src/shared/dynamic-tool-definition.d.ts +20 -0
- package/dist/src/shared/dynamic-tool-definition.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
function createEmptyHookRegistry(){return{
|
|
1
|
+
function createEmptyHookRegistry(){return{streamEventsByType:new Map,streamEventsWildcard:[]}}function createRuntimeHookRegistry(e){let t=new Map,n=[];for(let r of e)for(let[e,i]of Object.entries(r.events)){let a={slug:r.slug,handler:i,eventType:e};if(e===`*`)n.push(a);else{let n=t.get(e)??[];n.push(a),t.set(e,n)}}return{streamEventsByType:t,streamEventsWildcard:n}}export{createEmptyHookRegistry,createRuntimeHookRegistry};
|
|
@@ -5,9 +5,9 @@ import type { ResolvedHookDefinition } from "./types.js";
|
|
|
5
5
|
* Resolves one compiled authored hook into a runtime-owned definition
|
|
6
6
|
* with live handlers reattached from the authored module.
|
|
7
7
|
*
|
|
8
|
-
* The authored shape is `{
|
|
8
|
+
* The authored shape is `{ events?: { ... } }`.
|
|
9
9
|
* Each declared handler must be a function. Any other shape raises a
|
|
10
10
|
* {@link ResolveAgentError} so typos surface at resolve time instead of
|
|
11
|
-
* at first
|
|
11
|
+
* at first dispatch call.
|
|
12
12
|
*/
|
|
13
13
|
export declare function resolveHookDefinition(definition: CompiledHookDefinition, moduleMap: CompiledModuleMap, nodeId: string | undefined): Promise<ResolvedHookDefinition>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expectFunction,expectObjectRecord}from"../internal/authored-module.js";import{ResolveAgentError,loadResolvedModuleExport}from"./resolve-helpers.js";import{toErrorMessage}from"../shared/errors.js";async function resolveHookDefinition(a,o,s){try{let n=expectObjectRecord(await loadResolvedModuleExport({definition:a,kindLabel:`hook`,moduleMap:o,nodeId:s}),describe(a,`to return an object`)),i={},c=
|
|
1
|
+
import{expectFunction,expectObjectRecord}from"../internal/authored-module.js";import{ResolveAgentError,loadResolvedModuleExport}from"./resolve-helpers.js";import{toErrorMessage}from"../shared/errors.js";async function resolveHookDefinition(a,o,s){try{let n=expectObjectRecord(await loadResolvedModuleExport({definition:a,kindLabel:`hook`,moduleMap:o,nodeId:s}),describe(a,`to return an object`)),i={},c=n.events;if(c!==void 0){let n=expectObjectRecord(c,describe(a,"to expose `events` as an object"));for(let[t,r]of Object.entries(n))r!==void 0&&(i[t]=expectFunction(r,describe(a,`to provide a function for "events.${t}"`)))}return{events:i,exportName:a.exportName,logicalPath:a.logicalPath,slug:a.slug,sourceId:a.sourceId,sourceKind:`module`}}catch(e){throw e instanceof ResolveAgentError?e:new ResolveAgentError(`Failed to attach hook handlers from "${a.logicalPath}": ${toErrorMessage(e)}`,{logicalPath:a.logicalPath,sourceId:a.sourceId})}}function describe(e,t){return`Expected the hook export "${e.exportName??`default`}" from "${e.logicalPath}" ${t}.`}export{resolveHookDefinition};
|
|
@@ -6,7 +6,7 @@ import type { DiscoverDiagnosticsSummary } from "#discover/diagnostics.js";
|
|
|
6
6
|
import type { ChannelMethod, RouteContext } from "#public/definitions/channel.js";
|
|
7
7
|
import type { RouteHandler } from "#channel/routes.js";
|
|
8
8
|
import type { OutboundAuthFn } from "#public/agents/auth.js";
|
|
9
|
-
import type {
|
|
9
|
+
import type { StreamEventHook } from "#public/definitions/hook.js";
|
|
10
10
|
import type { CompactionInput, CompactionHookResult, NeedsApprovalContext, ToolModelOutput, ToolRetentionPolicy } from "#public/definitions/tool.js";
|
|
11
11
|
import type { AuthorizationDefinition, HeadersDefinition, ToolFilterDefinition } from "#runtime/connections/types.js";
|
|
12
12
|
import type { CompiledWorkspaceResourceRoot } from "#compiler/manifest.js";
|
|
@@ -148,8 +148,8 @@ export type ResolvedToolDefinition = Readonly<Optional<InternalToolDefinitionWit
|
|
|
148
148
|
};
|
|
149
149
|
/**
|
|
150
150
|
* Runtime-owned authored hook definition resolved from a compiled module
|
|
151
|
-
* map. Carries live
|
|
152
|
-
*
|
|
151
|
+
* map. Carries live stream-event handlers reattached from the authored
|
|
152
|
+
* module's exported nested maps.
|
|
153
153
|
*
|
|
154
154
|
* Per-handler validation runs at resolve time inside
|
|
155
155
|
* {@link resolveHookDefinition}; missing handlers are simply absent from
|
|
@@ -160,12 +160,6 @@ export interface ResolvedHookDefinition extends ResolvedModuleSourceRef {
|
|
|
160
160
|
* Path-relative slug used for diagnostics and ordering.
|
|
161
161
|
*/
|
|
162
162
|
readonly slug: string;
|
|
163
|
-
/**
|
|
164
|
-
* Lifecycle subscribers reattached from the authored
|
|
165
|
-
* `lifecycle: { session?, turn? }` map. Keys not present on the
|
|
166
|
-
* authored map are absent here.
|
|
167
|
-
*/
|
|
168
|
-
readonly lifecycle: LifecycleHooks;
|
|
169
163
|
/**
|
|
170
164
|
* Stream-event subscribers reattached from the authored
|
|
171
165
|
* `events: { ... }` map, keyed by event type. Includes the `*`
|
|
@@ -11,6 +11,14 @@ type ToolContext = SessionContext;
|
|
|
11
11
|
*/
|
|
12
12
|
export type DynamicToolEventName = Extract<HandleMessageStreamEvent["type"], "session.started" | "turn.started" | "step.started">;
|
|
13
13
|
export declare const ALLOWED_DYNAMIC_TOOL_EVENTS: ReadonlySet<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Instructions and skills are restricted to session/turn boundaries.
|
|
16
|
+
* They contribute to the system prompt, which is the most
|
|
17
|
+
* cache-sensitive position in the Anthropic wire format. Keeping them
|
|
18
|
+
* stable across steps within a turn maximizes cache hits.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ALLOWED_DYNAMIC_INSTRUCTION_EVENTS: ReadonlySet<string>;
|
|
21
|
+
export declare const ALLOWED_DYNAMIC_SKILL_EVENTS: ReadonlySet<string>;
|
|
14
22
|
/**
|
|
15
23
|
* Context passed to a dynamic resolver's event handler (tools and skills).
|
|
16
24
|
*
|
|
@@ -118,4 +126,16 @@ export declare const INSTRUCTIONS_BRAND: unique symbol;
|
|
|
118
126
|
* properly wrapped.
|
|
119
127
|
*/
|
|
120
128
|
export declare function isBrandedInstructionsEntry(value: unknown): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Symbol-based brand stamped by `defineSkill` on every entry. Invisible
|
|
131
|
+
* in IntelliSense but checked at runtime to detect single-entry vs
|
|
132
|
+
* map-of-entries return shapes in dynamic skill resolvers.
|
|
133
|
+
*/
|
|
134
|
+
export declare const SKILL_BRAND: unique symbol;
|
|
135
|
+
/**
|
|
136
|
+
* Returns true if `value` was stamped by `defineSkill` (has the brand
|
|
137
|
+
* symbol). Used to detect single entry vs map of entries, and to
|
|
138
|
+
* validate that entries are properly wrapped.
|
|
139
|
+
*/
|
|
140
|
+
export declare function isBrandedSkillEntry(value: unknown): boolean;
|
|
121
141
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const ALLOWED_DYNAMIC_TOOL_EVENTS=new Set([`session.started`,`turn.started`,`step.started`]),DYNAMIC_SENTINEL_KIND=`ash:dynamic`;function isDynamicSentinel(e){return typeof e==`object`&&!!e&&e.kind===`ash:dynamic`}const TOOL_BRAND=Symbol.for(`ash:tool-brand`);function isBrandedToolEntry(e){return typeof e==`object`&&!!e&&e[TOOL_BRAND]===!0}const INSTRUCTIONS_BRAND=Symbol.for(`ash:instructions-brand`);function isBrandedInstructionsEntry(e){return typeof e==`object`&&!!e&&e[INSTRUCTIONS_BRAND]===!0}export{ALLOWED_DYNAMIC_TOOL_EVENTS,DYNAMIC_SENTINEL_KIND,INSTRUCTIONS_BRAND,TOOL_BRAND,isBrandedInstructionsEntry,isBrandedToolEntry,isDynamicSentinel};
|
|
1
|
+
const ALLOWED_DYNAMIC_TOOL_EVENTS=new Set([`session.started`,`turn.started`,`step.started`]),ALLOWED_DYNAMIC_INSTRUCTION_EVENTS=new Set([`session.started`,`turn.started`]),ALLOWED_DYNAMIC_SKILL_EVENTS=new Set([`session.started`,`turn.started`]),DYNAMIC_SENTINEL_KIND=`ash:dynamic`;function isDynamicSentinel(e){return typeof e==`object`&&!!e&&e.kind===`ash:dynamic`}const TOOL_BRAND=Symbol.for(`ash:tool-brand`);function isBrandedToolEntry(e){return typeof e==`object`&&!!e&&e[TOOL_BRAND]===!0}const INSTRUCTIONS_BRAND=Symbol.for(`ash:instructions-brand`);function isBrandedInstructionsEntry(e){return typeof e==`object`&&!!e&&e[INSTRUCTIONS_BRAND]===!0}const SKILL_BRAND=Symbol.for(`ash:skill-brand`);function isBrandedSkillEntry(e){return typeof e==`object`&&!!e&&e[SKILL_BRAND]===!0}export{ALLOWED_DYNAMIC_INSTRUCTION_EVENTS,ALLOWED_DYNAMIC_SKILL_EVENTS,ALLOWED_DYNAMIC_TOOL_EVENTS,DYNAMIC_SENTINEL_KIND,INSTRUCTIONS_BRAND,SKILL_BRAND,TOOL_BRAND,isBrandedInstructionsEntry,isBrandedSkillEntry,isBrandedToolEntry,isDynamicSentinel};
|