@hosty-sdk/app 0.52.0 → 0.54.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 +10 -0
- package/dist/agent-client.js +2 -1
- package/dist/agent-schemas.js +1 -1
- package/dist/agent-server.js +3 -1
- package/dist/agent-sessions.d.ts +1 -0
- package/dist/agent-workflow-tools.d.ts +16 -0
- package/dist/agent-workflow-tools.js +83 -0
- package/dist/agent.d.ts +4 -1
- package/dist/agent.js +3 -1
- package/dist/assistant.d.ts +1 -0
- package/dist/assistant.js +2 -1
- package/dist/providers-server.d.ts +15 -8
- package/dist/providers-server.js +40 -3
- package/dist/providers.d.ts +26 -1
- package/dist/tasks-server.js +2 -1
- package/dist/tasks.d.ts +1 -0
- package/dist/tasks.js +1 -1
- package/package.json +5 -1
- package/schemas/agent-event-v1.schema.json +12 -0
- package/schemas/agent-v1.openapi.json +12 -0
package/README.md
CHANGED
|
@@ -303,6 +303,16 @@ their existing behavior. Validate the selected provider's duration/byte capabili
|
|
|
303
303
|
credentials and the acting user's access. It does not expose general agent execution.
|
|
304
304
|
See [Provider consumption](../../docs/features/provider-consumption/feature.md) for the full contract.
|
|
305
305
|
|
|
306
|
+
### Named implementations and read-aloud
|
|
307
|
+
|
|
308
|
+
Call `listImplementations("speech-to-text")` or `listImplementations("text-to-speech")` to list both
|
|
309
|
+
static and named entries. Keep the installation, key and implementation ID with each choice. The
|
|
310
|
+
`displayName` is the current human-readable label. Pass the selection to `speechCapabilities`
|
|
311
|
+
and `transcribe`, or to `textToSpeechCapabilities` and `synthesize(selected, { text }, signal)`.
|
|
312
|
+
Synthesis returns a streaming fetch Response. Abort or cancel its body to stop the request.
|
|
313
|
+
The provider backend publishes with `publishImplementations` and resolves the exact implementation
|
|
314
|
+
from `validate` on each request. See the [app manifest guide](../../skills/hosty-app-skill/references/app-manifest.md#named-provider-implementations).
|
|
315
|
+
|
|
306
316
|
## Tasks And Execution Providers
|
|
307
317
|
|
|
308
318
|
Core 0.159.0 and SDK 0.36.0 support independent `tasks` and `task-executor` categories. Request
|
package/dist/agent-client.js
CHANGED
|
@@ -8,7 +8,8 @@ const segment = (id) => {
|
|
|
8
8
|
throw new AgentApiError("invalid_input", "A bounded opaque resource ID is required.", 400);
|
|
9
9
|
return encodeURIComponent(id);
|
|
10
10
|
};
|
|
11
|
-
const sameProvider = (a, b) => a.appId === b.appId && a.installationId === b.installationId && a.key === b.key
|
|
11
|
+
const sameProvider = (a, b) => a.appId === b.appId && a.installationId === b.installationId && a.key === b.key
|
|
12
|
+
&& (a.implementationId ?? null) === (b.implementationId ?? null);
|
|
12
13
|
/** Preparing once lets an application persist exactly the bytes it must reuse after an uncertain delivery. */
|
|
13
14
|
export function prepareAgentRequest(operation, method, path, input, metadata = {}) {
|
|
14
15
|
const body = JSON.stringify(input);
|
package/dist/agent-schemas.js
CHANGED
|
@@ -22,7 +22,7 @@ const historyObservation = {
|
|
|
22
22
|
object({ kind: { const: "event" }, event: ref("Event"), cursor: text(8192) })] },
|
|
23
23
|
};
|
|
24
24
|
export const AGENT_SCHEMAS = {
|
|
25
|
-
ProviderRef: object(refProperties),
|
|
25
|
+
ProviderRef: object({ ...refProperties, implementationId: { anyOf: [text(128), { type: "null" }] } }, Object.keys(refProperties)),
|
|
26
26
|
QualifiedRef: object({ provider: ref("ProviderRef"), id }),
|
|
27
27
|
Instruction: object({ id: text(128), text: { type: "string", maxLength: 262144 } }),
|
|
28
28
|
Skill: object({ skillId: digest, expectedDigest: digest }, ["skillId"]),
|
package/dist/agent-server.js
CHANGED
|
@@ -20,7 +20,9 @@ function strings(value, max = 128, width = 256) {
|
|
|
20
20
|
fail("Selections require distinct bounded strings.");
|
|
21
21
|
}
|
|
22
22
|
function provider(value) {
|
|
23
|
-
shape(value, ["appId", "installationId", "key"], "provider reference");
|
|
23
|
+
shape(value, ["appId", "installationId", "key", "implementationId"], "provider reference");
|
|
24
|
+
if (value.implementationId != null && !bounded(value.implementationId, 128))
|
|
25
|
+
fail("Invalid named implementation ID.");
|
|
24
26
|
if (![value.appId, value.installationId, value.key].every(v => bounded(v)))
|
|
25
27
|
fail("An installation-qualified provider reference is required.");
|
|
26
28
|
}
|
package/dist/agent-sessions.d.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AgentSessionWorkflowTool } from "./agent.js";
|
|
2
|
+
export declare const workflowTools: (selected?: readonly AgentSessionWorkflowTool[]) => {
|
|
3
|
+
name: "task_executor_options" | "task_options" | "task_list" | "task_get" | "task_create" | "task_edit" | "task_action" | "task_result" | "task_fail" | "task_request_input" | "task_adopt" | "task_prepare_executor" | "task_delegate" | "task_wait" | "task_plan" | "task_bind_workspace" | "task_execution_get" | "subagent_profiles" | "subagent_spawn" | "subagent_status" | "subagent_wait";
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: Record<string, unknown>;
|
|
8
|
+
required: string[];
|
|
9
|
+
additionalProperties: boolean;
|
|
10
|
+
};
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: boolean;
|
|
13
|
+
destructiveHint: boolean;
|
|
14
|
+
openWorldHint: boolean;
|
|
15
|
+
};
|
|
16
|
+
}[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AGENT_SESSION_WORKFLOW_TOOLS, AGENT_SUBAGENT_WORKFLOW_TOOLS } from "./agent.js";
|
|
2
|
+
const object = (properties, required = []) => ({ type: "object", properties, required, additionalProperties: false });
|
|
3
|
+
const id = { type: "string", format: "uuid" }, revision = { type: "integer", minimum: 1 }, counter = { type: "integer", minimum: 0 };
|
|
4
|
+
const text = (maxLength) => ({ type: "string", maxLength });
|
|
5
|
+
const provider = object({ appId: text(200), installationId: text(200), key: text(100), implementationId: { oneOf: [text(128), { type: "null" }] } }, ["appId", "installationId", "key"]);
|
|
6
|
+
const ref = object({ ...provider.properties, id }, ["appId", "installationId", "key", "id"]);
|
|
7
|
+
const refs = { type: "array", items: ref, maxItems: 100 };
|
|
8
|
+
const selection = object({ kind: { enum: ["option", "configuration"] }, id: text(200), revision }, ["kind", "id", "revision"]);
|
|
9
|
+
const resource = object({ kind: { enum: ["app", "workspace", "external"] }, owner: text(200), id: text(2000), label: text(200),
|
|
10
|
+
version: { oneOf: [object({ mode: { const: "live" } }, ["mode"]), object({ mode: { const: "pinned" }, revision: text(200) }, ["mode", "revision"])] } }, ["kind", "owner", "id", "version"]);
|
|
11
|
+
const resources = { type: "array", items: resource, maxItems: 32 };
|
|
12
|
+
const review = object({ mode: { enum: ["none", "owner", "delegator"] } }, ["mode"]);
|
|
13
|
+
const assignee = { oneOf: [{ type: "null" }, object({ kind: { const: "human" }, userId: text(200), name: text(200) }, ["kind", "userId"]),
|
|
14
|
+
object({ kind: { const: "app" }, executor: provider, selection, name: text(200) }, ["kind", "executor"])] };
|
|
15
|
+
const input = object({ title: text(200), markdown: text(32000), assignee, review, resources, parentTaskRef: { oneOf: [ref, { type: "null" }] }, dependsOn: refs }, ["title", "markdown", "assignee", "resources"]);
|
|
16
|
+
const outcome = object({ taskRef: ref, inputRevision: revision, executionId: { oneOf: [id, { type: "null" }] }, resultRevision: revision }, ["taskRef", "inputRevision", "executionId", "resultRevision"]);
|
|
17
|
+
const result = object({ markdown: text(32000), resources }, ["markdown", "resources"]);
|
|
18
|
+
const requestId = { ...id, description: "A fresh globally unique UUID for a new operation. Never reuse sample IDs or IDs from another chat or task. Retain this exact UUID and input only when recovering the same operation." };
|
|
19
|
+
const mutation = { requestId, expectedRevision: revision };
|
|
20
|
+
const writeScope = object({ mode: { enum: ["read", "write", "exclusive"] }, paths: { type: "array", items: text(2000), maxItems: 100 } }, ["mode", "paths"]);
|
|
21
|
+
const schemas = {
|
|
22
|
+
"subagent-profiles": object({}),
|
|
23
|
+
"subagent-spawn": object({ requestId, profileId: text(200), profileRevision: revision, prompt: text(32000), title: text(200) }, ["requestId", "profileId", "profileRevision", "prompt"]),
|
|
24
|
+
"subagent-status": object({ childSessionId: id }),
|
|
25
|
+
"subagent-wait": object({ requestId, childSessionIds: { type: "array", items: id, minItems: 1, maxItems: 100 }, mode: { enum: ["any", "all"] } }, ["requestId", "childSessionIds", "mode"]),
|
|
26
|
+
"task-executor-options": object({}),
|
|
27
|
+
"task-options": object({ executor: provider }),
|
|
28
|
+
"task-list": object({ cursor: text(200), limit: { type: "integer", minimum: 1, maximum: 100 }, status: { enum: ["Draft", "Ready", "InProgress", "Blocked", "Done", "Cancelled"] }, parentTaskRef: ref, rootTaskRef: ref, rootsOnly: { type: "boolean" }, removed: { type: "boolean" } }),
|
|
29
|
+
"task-get": object({ taskId: id }, ["taskId"]),
|
|
30
|
+
"task-create": object({ requestId, expectedGraphRevision: revision, input }, ["requestId", "input"]),
|
|
31
|
+
"task-edit": object({ ...mutation, taskId: id, expectedGraphRevision: revision, input }, ["requestId", "expectedRevision", "taskId", "expectedGraphRevision", "input"]),
|
|
32
|
+
"task-action": object({ ...mutation, taskId: id, action: { enum: ["ready", "draft", "start", "complete", "cancel", "accept", "request_changes", "retry", "disposition", "remove", "restore"] },
|
|
33
|
+
removalScope: { type: "array", minItems: 1, maxItems: 100, items: object({ taskRef: ref, revision }, ["taskRef", "revision"]) },
|
|
34
|
+
result, resultRef: outcome, feedback: text(4000), selection,
|
|
35
|
+
disposition: object({ kind: { enum: ["superseded", "not_required"] }, reason: text(2000), replacementRefs: refs }, ["kind", "reason", "replacementRefs"]) }, ["requestId", "expectedRevision", "taskId", "action"]),
|
|
36
|
+
"task-result": object({ requestId, completed: { const: true, description: "Attest that the requested work and required checks are complete; an unfinished blocker is not success." }, result }, ["requestId", "completed", "result"]),
|
|
37
|
+
"task-fail": object({ requestId, result }, ["requestId", "result"]),
|
|
38
|
+
"task-request-input": object({ requestId, reason: text(2000), questions: { type: "array", minItems: 1, maxItems: 4,
|
|
39
|
+
items: object({ id: text(100), header: text(100), question: text(4000), isOther: { type: "boolean" },
|
|
40
|
+
options: { type: "array", maxItems: 8, items: object({ label: text(500), description: text(2000) }, ["label", "description"]) } }, ["id", "header", "question"]) } }, ["requestId", "reason", "questions"]),
|
|
41
|
+
"task-adopt": object({ requestId, title: text(200), markdown: text(32000), resources, review,
|
|
42
|
+
selectionRevision: counter, contextRevision: counter, autonomyRevision: counter }, ["requestId", "title", "markdown", "resources", "selectionRevision", "contextRevision", "autonomyRevision"]),
|
|
43
|
+
"task-prepare-executor": object({ requestId, directoryRevision: counter, option: object({ id: text(200), revision }, ["id", "revision"]),
|
|
44
|
+
name: text(100), rationale: text(2000), instructions: text(32000), skillIds: { type: "array", items: text(200), maxItems: 64 } }, ["requestId", "directoryRevision"]),
|
|
45
|
+
"task-delegate": object({ requestId, expectedGraphRevision: revision, title: text(200), markdown: text(32000), resources, selection,
|
|
46
|
+
rationale: text(2000), dependsOn: refs, writeScope }, ["requestId", "expectedGraphRevision", "title", "markdown", "resources", "selection", "rationale"]),
|
|
47
|
+
"task-wait": object({ requestId, children: refs, mode: { enum: ["any", "all"] },
|
|
48
|
+
observed: { type: "array", maxItems: 100, items: object({ taskRef: ref, taskRevision: counter }, ["taskRef", "taskRevision"]) } }, ["requestId", "children", "mode"]),
|
|
49
|
+
"task-plan": object({ requestId, expectedRevision: counter, markdown: text(32000) }, ["requestId", "expectedRevision", "markdown"]),
|
|
50
|
+
"task-bind-workspace": object({ requestId, expectedRevision: counter, workspaceId: text(200),
|
|
51
|
+
prepare: object({ appId: text(200), name: text(120), targetBranch: text(200) }, ["appId", "name"]) }, ["requestId", "expectedRevision"]),
|
|
52
|
+
"task-execution-get": object({ cursor: text(200), limit: { type: "integer", minimum: 1, maximum: 100 } }),
|
|
53
|
+
};
|
|
54
|
+
const descriptions = {
|
|
55
|
+
"subagent-profiles": "List saved agent profiles and their current revisions for a child chat.",
|
|
56
|
+
"subagent-spawn": "Open a child chat with the selected profile and prompt. Reuse the request UUID only to recover this exact delegation.",
|
|
57
|
+
"subagent-status": "Read the state and available results of this chat’s children. Supply a child session ID to inspect one.",
|
|
58
|
+
"subagent-wait": "Register a durable wait for the selected direct children. If pending, yield this turn. The parent receives the outcome when the condition is met.",
|
|
59
|
+
"task-executor-options": "Read the owning consumer executor directory: saved profile descriptions, immutable revisions and availability. Use this session-owned tool to choose task performers and recheck setup after a Decision. It never creates profiles.",
|
|
60
|
+
"task-options": "Read the current executor directory: profile descriptions, immutable selection revisions and known availability. Choose existing profiles first.",
|
|
61
|
+
"task-list": "List visible tasks with optional ancestry filters; in an admitted execution, read the current tree.",
|
|
62
|
+
"task-get": "Read a task's current revisions, accepted outcomes and retained attempts before changing it.",
|
|
63
|
+
"task-create": "Create a Draft task, preserving requestId on retry. An admitted execution creates only direct children of its bound task; use task_delegate for armed delegated work.",
|
|
64
|
+
"task-edit": "Replace a stopped Draft's input with current task and graph revisions. Parent is immutable.",
|
|
65
|
+
"task-action": "Apply a common lifecycle action. Review direct children using exact resultRef; request_changes needs feedback. Retry only after confirmed stop, preserving the task and its history. remove/restore require the complete reviewed removalScope of taskRef and revision, preserve history and resources, and are unavailable to task-bound agents.",
|
|
66
|
+
"task-result": "Report successful completion only after required work, child review and verification. Set completed=true to attest success. Never report an unfinished blocker here. Then finish the turn.",
|
|
67
|
+
"task-fail": "Report an unsuccessful terminal attempt with diagnostic evidence, then finish. This leaves the task Blocked, not Done. For missing human input use task_request_input instead so the same attempt can continue.",
|
|
68
|
+
"task-request-input": "Request mandatory human information or setup intervention for this task through Decisions. Supply stable question IDs and a reason; never request secrets. After the durable acknowledgement, yield immediately without task_result or polling. The same task resumes after the answer; recheck setup prerequisites against real state. Use native nonblocking questions only for optional clarification.",
|
|
69
|
+
"task-adopt": "Start task work from chat by creating or recovering one root and adopting this same session. Read session revisions with task_execution_get first. Normal mode requires the owner's Decisions approval; never launch children before admission.",
|
|
70
|
+
"task-prepare-executor": "Choose a saved option at the current directory revision. Only when no profile fits, supply name, rationale, instructions and installed skillIds for a one-off child. It inherits this session's connection/model; no catalog profile is created.",
|
|
71
|
+
"task-delegate": "Create and arm a direct child under this admitted task with the chosen selection and rationale. Dependencies require accepted results; every child has a fresh session and delegator review. Unknown write scope is exclusive.",
|
|
72
|
+
"task-wait": "Register a durable wait for direct child outcomes. Include each observed child taskRevision to avoid replaying known results; task revisions remain monotonic across execution attempts. If pending, yield the turn immediately: Worker parks it and resumes the same context after a relevant result or failure, without polling.",
|
|
73
|
+
"task-plan": "Save a versioned execution plan for this root without altering its admitted objective. Use expectedRevision 0 for the first plan.",
|
|
74
|
+
"task-bind-workspace": "Select or prepare the root's optional authorized workspace. All descendant and retained sessions share its association. This grants no lifecycle or publication authority.",
|
|
75
|
+
"task-execution-get": "Read this session's task binding, root plan, limits and bounded child results. Before adoption, read the current session revisions and mode.",
|
|
76
|
+
};
|
|
77
|
+
/** Fixed business tools only. Their schemas grant no native, Core MCP or source authority. */
|
|
78
|
+
const knownTools = [...AGENT_SESSION_WORKFLOW_TOOLS, ...AGENT_SUBAGENT_WORKFLOW_TOOLS];
|
|
79
|
+
export const workflowTools = (selected = AGENT_SESSION_WORKFLOW_TOOLS) => knownTools.filter(name => selected.includes(name)).map(name => {
|
|
80
|
+
const action = name.replaceAll("_", "-");
|
|
81
|
+
return { name, description: descriptions[action], inputSchema: object(name.startsWith("subagent_") ? { input: schemas[action] } : { input: schemas[action], source: provider }, ["input"]),
|
|
82
|
+
annotations: { readOnlyHint: ["subagent_profiles", "subagent_status", "task_executor_options", "task_options", "task_list", "task_get", "task_execution_get"].includes(name), destructiveHint: name === "task_action", openWorldHint: false } };
|
|
83
|
+
});
|
package/dist/agent.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare const AGENT_CAPABILITIES: {
|
|
|
29
29
|
readonly approvalMode: "configuration.approval-mode";
|
|
30
30
|
readonly mcpPolicy: "mcp.policy-update";
|
|
31
31
|
readonly consumerWorkflow: "workflow.consumer";
|
|
32
|
+
readonly sessionSubagents: "workflow.subagents";
|
|
32
33
|
};
|
|
33
34
|
export type AgentCapability = typeof AGENT_CAPABILITIES[keyof typeof AGENT_CAPABILITIES] | (string & {});
|
|
34
35
|
export type AgentLimits = {
|
|
@@ -505,7 +506,8 @@ export type AgentOperation = "capabilities" | "connections.list" | "connections.
|
|
|
505
506
|
/** Core transport names for the optional consumer-bound task workflow, without general Core tools. */
|
|
506
507
|
export declare const AGENT_SESSION_WORKFLOW_TOOLS: readonly ["task_executor_options", "task_options", "task_list", "task_get", "task_create", "task_edit", "task_action", "task_result", "task_fail", "task_request_input", "task_adopt", "task_prepare_executor", "task_delegate", "task_wait", "task_plan", "task_bind_workspace", "task_execution_get"];
|
|
507
508
|
/** Optional business workflow owned by the invoking consumer, separate from native execution. */
|
|
508
|
-
export
|
|
509
|
+
export declare const AGENT_SUBAGENT_WORKFLOW_TOOLS: readonly ["subagent_profiles", "subagent_spawn", "subagent_status", "subagent_wait"];
|
|
510
|
+
export type AgentSessionWorkflowTool = typeof AGENT_SESSION_WORKFLOW_TOOLS[number] | typeof AGENT_SUBAGENT_WORKFLOW_TOOLS[number];
|
|
509
511
|
export type AgentSessionWorkflowBinding = {
|
|
510
512
|
executor: ProviderRef;
|
|
511
513
|
sessionId: string;
|
|
@@ -553,6 +555,7 @@ export type AgentOperationAuthorization = {
|
|
|
553
555
|
token: string;
|
|
554
556
|
expiresAt: string;
|
|
555
557
|
admissionRef?: string;
|
|
558
|
+
supportedWorkflowCapabilities?: string[];
|
|
556
559
|
};
|
|
557
560
|
export type AgentAuthorizer = (request: AgentAuthorizationRequest, signal?: AbortSignal) => Promise<AgentOperationAuthorization>;
|
|
558
561
|
/** Persist this value before a mutation; body is the exact UTF-8 JSON string used on every retry. */
|
package/dist/agent.js
CHANGED
|
@@ -10,7 +10,7 @@ export const AGENT_CAPABILITIES = {
|
|
|
10
10
|
barrier: "runs.barrier", reconcile: "runs.reconcile", retire: "runs.retire", liveConfigure: "runs.live-configure",
|
|
11
11
|
predictions: "predictions", connectionUsage: "connections.usage",
|
|
12
12
|
approvalMode: "configuration.approval-mode",
|
|
13
|
-
mcpPolicy: "mcp.policy-update", consumerWorkflow: "workflow.consumer",
|
|
13
|
+
mcpPolicy: "mcp.policy-update", consumerWorkflow: "workflow.consumer", sessionSubagents: "workflow.subagents",
|
|
14
14
|
};
|
|
15
15
|
export class AgentApiError extends Error {
|
|
16
16
|
code;
|
|
@@ -34,3 +34,5 @@ export const AGENT_SESSION_WORKFLOW_TOOLS = [
|
|
|
34
34
|
"task_result", "task_fail", "task_request_input", "task_adopt", "task_prepare_executor", "task_delegate",
|
|
35
35
|
"task_wait", "task_plan", "task_bind_workspace", "task_execution_get",
|
|
36
36
|
];
|
|
37
|
+
/** Optional business workflow owned by the invoking consumer, separate from native execution. */
|
|
38
|
+
export const AGENT_SUBAGENT_WORKFLOW_TOOLS = ["subagent_profiles", "subagent_spawn", "subagent_status", "subagent_wait"];
|
package/dist/assistant.d.ts
CHANGED
package/dist/assistant.js
CHANGED
|
@@ -48,7 +48,8 @@ export function resolveAssistantPresentation(provider, result, options) {
|
|
|
48
48
|
const expected = options.expectedProvider;
|
|
49
49
|
if (!provider.installationId)
|
|
50
50
|
throw new AssistantError("unsupported_core", "Update Core to identify assistant installations.", 409);
|
|
51
|
-
if (provider.appId !== expected.appId || provider.key !== expected.key || provider.installationId !== expected.installationId
|
|
51
|
+
if (provider.appId !== expected.appId || provider.key !== expected.key || provider.installationId !== expected.installationId
|
|
52
|
+
|| (provider.implementationId ?? null) !== (expected.implementationId ?? null))
|
|
52
53
|
throw new AssistantError("provider_changed", "The original assistant installation is no longer available.", 409);
|
|
53
54
|
try {
|
|
54
55
|
resolveAssistantDestination(result.open, provider.uiSurfaces ?? []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HistoryExportGrant, HistoryExportAcknowledge, HistoryExportQuery, HistoryExportSnapshot, HistoryChangePage } from "./history.js";
|
|
2
2
|
import { AssistantClient } from "@hosty-sdk/app/assistant";
|
|
3
|
-
import { type AppPermissionState, type ProviderDescriptor, type ProviderInvocation, type ProviderKind, type MediatedProviderInvocation, type MediatedProviderRequest, type SpeechCapabilities, type SpeechResult, type TranslationRequest, type TranslationResult, type TranslationCapabilities } from "@hosty-sdk/app/providers";
|
|
3
|
+
import { type AppPermissionState, type ProviderDescriptor, type ProviderInvocation, type ProviderKind, type MediatedProviderInvocation, type MediatedProviderRequest, type SpeechCapabilities, type SpeechResult, type TranslationRequest, type TranslationResult, type TranslationCapabilities, type ProviderSelection, type ProviderImplementationSnapshot, type TextToSpeechCapabilities, type SpeechSynthesisRequest } from "@hosty-sdk/app/providers";
|
|
4
4
|
export type ProviderServerOptions = {
|
|
5
5
|
appId?: string;
|
|
6
6
|
coreOrigin?: string;
|
|
@@ -32,25 +32,32 @@ export declare class ProviderClient {
|
|
|
32
32
|
historyExportChanges(input: HistoryExportQuery, signal?: AbortSignal): Promise<HistoryChangePage>;
|
|
33
33
|
permissions(signal?: AbortSignal): Promise<AppPermissionState>;
|
|
34
34
|
list(kind: ProviderKind, signal?: AbortSignal): Promise<ProviderDescriptor[]>;
|
|
35
|
+
/** Discover static and named implementations. Retain the complete selection across calls. */
|
|
36
|
+
listImplementations(kind: ProviderKind, signal?: AbortSignal): Promise<ProviderDescriptor[]>;
|
|
37
|
+
/** Replace this installation's complete snapshot for one reviewed interface entry. */
|
|
38
|
+
publishImplementations(kind: ProviderKind, key: string, snapshot: ProviderImplementationSnapshot, signal?: AbortSignal): Promise<{
|
|
39
|
+
revision: number;
|
|
40
|
+
}>;
|
|
35
41
|
private connect;
|
|
36
|
-
speechCapabilities(provider:
|
|
37
|
-
transcribe(provider:
|
|
42
|
+
speechCapabilities(provider: ProviderSelection, signal?: AbortSignal): Promise<SpeechCapabilities>;
|
|
43
|
+
transcribe(provider: ProviderSelection, audio: Blob, options?: {
|
|
38
44
|
language?: string;
|
|
39
45
|
signal?: AbortSignal; /** Total deadline, 1–930000 ms; defaults to five minutes. */
|
|
40
46
|
timeoutMs?: number;
|
|
41
47
|
}): Promise<SpeechResult>;
|
|
42
|
-
|
|
48
|
+
textToSpeechCapabilities(provider: ProviderSelection, signal?: AbortSignal): Promise<TextToSpeechCapabilities>;
|
|
49
|
+
/** Stream 24 kHz mono signed 16-bit little-endian PCM. Cancel the signal or response body to stop. */
|
|
50
|
+
synthesize(provider: ProviderSelection, input: SpeechSynthesisRequest, signal?: AbortSignal): Promise<Response>;
|
|
51
|
+
translationCapabilities(provider: ProviderSelection, signal?: AbortSignal, options?: {
|
|
43
52
|
connection: {
|
|
44
53
|
id: string;
|
|
45
54
|
revision: string;
|
|
46
55
|
};
|
|
47
56
|
}): Promise<TranslationCapabilities>;
|
|
48
57
|
/** Translate text or Markdown through the explicitly selected provider; never retries or falls back. */
|
|
49
|
-
translate(provider:
|
|
58
|
+
translate(provider: ProviderSelection, input: TranslationRequest, signal?: AbortSignal): Promise<TranslationResult>;
|
|
50
59
|
/** User-attributed requests preserve the assistant's existing handoff and dispatch policy. */
|
|
51
|
-
assistant(provider:
|
|
52
|
-
installationId?: string | null;
|
|
53
|
-
}, userToken: () => Promise<string>): Promise<AssistantClient>;
|
|
60
|
+
assistant(provider: ProviderSelection, userToken: () => Promise<string>): Promise<AssistantClient>;
|
|
54
61
|
/** Bounded task protocol transport. The selected installation is checked on every operation. */
|
|
55
62
|
taskRequest<T>(provider: import("./tasks.js").TaskProviderRef, kind: "tasks" | "task-executor", route: string, method: string, input?: unknown, userToken?: () => Promise<string>, signal?: AbortSignal): Promise<T>;
|
|
56
63
|
/** Validate an operation-bound Core credential against this exact request. Source ACL checks remain mandatory. */
|
package/dist/providers-server.js
CHANGED
|
@@ -48,12 +48,25 @@ export class ProviderClient {
|
|
|
48
48
|
async list(kind, signal) {
|
|
49
49
|
return (await this.coreRequest(`/providers/${kind}`, undefined, signal)).providers;
|
|
50
50
|
}
|
|
51
|
+
/** Discover static and named implementations. Retain the complete selection across calls. */
|
|
52
|
+
async listImplementations(kind, signal) {
|
|
53
|
+
return (await this.coreRequest(`/providers/${kind}?named=true`, undefined, signal)).providers;
|
|
54
|
+
}
|
|
55
|
+
/** Replace this installation's complete snapshot for one reviewed interface entry. */
|
|
56
|
+
publishImplementations(kind, key, snapshot, signal) {
|
|
57
|
+
return this.coreRequest(`/providers/${kind}/implementations`, { key, revision: snapshot.revision, implementations: snapshot.implementations }, signal);
|
|
58
|
+
}
|
|
51
59
|
async connect(provider, signal, userToken) {
|
|
52
|
-
|
|
60
|
+
if (provider.implementationId != null && !provider.installationId)
|
|
61
|
+
throw new ProviderError("provider_selection_invalid", "A named implementation requires an installation.", 400);
|
|
62
|
+
const issued = await this.coreRequest(`/providers/${provider.kind}/token`, { providerAppId: provider.appId, key: provider.key, installationId: provider.installationId, implementationId: provider.implementationId }, signal, userToken);
|
|
63
|
+
if (issued.provider.appId !== provider.appId || issued.provider.kind !== provider.kind || issued.provider.key !== provider.key
|
|
64
|
+
|| (issued.provider.implementationId ?? null) !== (provider.implementationId ?? null))
|
|
65
|
+
throw new ProviderError("provider_changed", "The selected provider binding changed.", 409);
|
|
53
66
|
if (issued.provider.version !== 1 || !issued.provider.url)
|
|
54
67
|
throw new ProviderError("provider_incompatible", "This provider does not support interface version 1.", 409);
|
|
55
68
|
if (provider.installationId && issued.provider.installationId !== provider.installationId)
|
|
56
|
-
throw new ProviderError("provider_changed", "The selected
|
|
69
|
+
throw new ProviderError("provider_changed", "The selected provider installation changed. Select it again.", 409);
|
|
57
70
|
const url = new URL(issued.provider.url);
|
|
58
71
|
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password)
|
|
59
72
|
throw new ProviderError("provider_url_invalid", "Invalid provider endpoint.", 409);
|
|
@@ -92,6 +105,30 @@ export class ProviderClient {
|
|
|
92
105
|
await dispatcher.close();
|
|
93
106
|
}
|
|
94
107
|
}
|
|
108
|
+
async textToSpeechCapabilities(provider, signal) {
|
|
109
|
+
const binding = await this.connect({ ...provider, kind: "text-to-speech" }, signal);
|
|
110
|
+
const deadline = AbortSignal.timeout(10_000);
|
|
111
|
+
return read(await fetch(`${binding.url}/capabilities`, { redirect: "error", signal: signal ? AbortSignal.any([signal, deadline]) : deadline,
|
|
112
|
+
headers: { authorization: `Bearer ${binding.token}` } }));
|
|
113
|
+
}
|
|
114
|
+
/** Stream 24 kHz mono signed 16-bit little-endian PCM. Cancel the signal or response body to stop. */
|
|
115
|
+
async synthesize(provider, input, signal) {
|
|
116
|
+
if (typeof input.text !== "string" || !input.text.trim() || input.text.length > 4000)
|
|
117
|
+
throw new ProviderError("speech_text_invalid", "Provide between 1 and 4000 UTF-16 code units of text.", 400);
|
|
118
|
+
const timeout = AbortSignal.timeout(300_000);
|
|
119
|
+
const deadline = signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
120
|
+
const binding = await this.connect({ ...provider, kind: "text-to-speech" }, deadline);
|
|
121
|
+
const response = await fetch(`${binding.url}/speech`, { method: "POST", redirect: "error", signal: deadline,
|
|
122
|
+
headers: { authorization: `Bearer ${binding.token}`, "content-type": "application/json", accept: "audio/pcm" },
|
|
123
|
+
body: JSON.stringify({ text: input.text }) });
|
|
124
|
+
if (!response.ok)
|
|
125
|
+
await read(response);
|
|
126
|
+
if (!response.body || !/^audio\/pcm\s*;\s*rate=24000\s*$/i.test(response.headers.get("content-type") ?? "")) {
|
|
127
|
+
await response.body?.cancel();
|
|
128
|
+
throw new ProviderError("provider_response_invalid", "Expected a 24 kHz PCM audio stream.", 502);
|
|
129
|
+
}
|
|
130
|
+
return response;
|
|
131
|
+
}
|
|
95
132
|
async translationCapabilities(provider, signal, options) {
|
|
96
133
|
const connection = options?.connection;
|
|
97
134
|
if (options && (!connection || typeof connection.id !== "string" || !connection.id || connection.id.length > 200
|
|
@@ -154,7 +191,7 @@ export class ProviderClient {
|
|
|
154
191
|
const execution = invocation.agentExecution;
|
|
155
192
|
const identity = (value) => typeof value === "string" && value.length > 0 && value.length <= 512
|
|
156
193
|
&& value.trim() === value && !/[\u0000-\u001f\u007f]/.test(value);
|
|
157
|
-
if (request.operation === "session.workflow" && (kind !== "task-executor" || !execution)
|
|
194
|
+
if (request.operation === "session.workflow" && ((kind !== "task-executor" && kind !== "agent-sessions") || !execution)
|
|
158
195
|
|| execution && (!identity(execution.sessionId) || !identity(execution.runId)
|
|
159
196
|
|| !execution.provider || !identity(execution.provider.appId) || !identity(execution.provider.installationId) || !identity(execution.provider.key)))
|
|
160
197
|
throw new ProviderError("token_invalid", "Core returned an invalid admitted agent workflow binding.", 401);
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Provider categories supported by Core. Task execution does not expose model/profile configuration. */
|
|
2
|
-
export type ProviderKind = "agent" | "speech-to-text" | "assistant" | "translation" | "tasks" | "task-executor" | "conversation-history" | "agent-sessions";
|
|
2
|
+
export type ProviderKind = "agent" | "speech-to-text" | "text-to-speech" | "assistant" | "translation" | "tasks" | "task-executor" | "conversation-history" | "agent-sessions";
|
|
3
3
|
export type ProviderDescriptor = {
|
|
4
4
|
appId: string;
|
|
5
5
|
displayName: string;
|
|
@@ -19,6 +19,19 @@ export type ProviderDescriptor = {
|
|
|
19
19
|
}> | null;
|
|
20
20
|
/** Opaque Core installation identity; compare for equality, never parse. */
|
|
21
21
|
installationId?: string | null;
|
|
22
|
+
/** Opaque provider-owned ID, scoped to this installation, kind and declared key. */
|
|
23
|
+
implementationId?: string | null;
|
|
24
|
+
implementationName?: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type ProviderSelection = Pick<ProviderDescriptor, "appId" | "key" | "installationId" | "implementationId">;
|
|
27
|
+
export type ProviderImplementation = {
|
|
28
|
+
id: string;
|
|
29
|
+
displayName: string;
|
|
30
|
+
available: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type ProviderImplementationSnapshot = {
|
|
33
|
+
revision: number;
|
|
34
|
+
implementations: ProviderImplementation[];
|
|
22
35
|
};
|
|
23
36
|
export type AppPermissionState = {
|
|
24
37
|
required: string[];
|
|
@@ -35,6 +48,7 @@ export type ProviderInvocation = {
|
|
|
35
48
|
hostRole: string | null;
|
|
36
49
|
kind: ProviderKind;
|
|
37
50
|
key: string;
|
|
51
|
+
implementationId?: string | null;
|
|
38
52
|
};
|
|
39
53
|
/** Core-mediated v2 invocations carry the original principal; direct clients have no app identity. */
|
|
40
54
|
export type MediatedProviderInvocation = {
|
|
@@ -49,6 +63,7 @@ export type MediatedProviderInvocation = {
|
|
|
49
63
|
principalId: string;
|
|
50
64
|
kind: ProviderKind;
|
|
51
65
|
key: string;
|
|
66
|
+
implementationId?: string | null;
|
|
52
67
|
operation: string;
|
|
53
68
|
resourceIds: string[];
|
|
54
69
|
taskDispatch?: TaskDispatchRef | null;
|
|
@@ -84,6 +99,16 @@ export type SpeechCapabilities = {
|
|
|
84
99
|
backend: string;
|
|
85
100
|
ready: boolean;
|
|
86
101
|
};
|
|
102
|
+
export type TextToSpeechCapabilities = {
|
|
103
|
+
version: 1;
|
|
104
|
+
mediaTypes: string[];
|
|
105
|
+
maxCharacters: number;
|
|
106
|
+
backend: string;
|
|
107
|
+
ready: boolean;
|
|
108
|
+
};
|
|
109
|
+
export type SpeechSynthesisRequest = {
|
|
110
|
+
text: string;
|
|
111
|
+
};
|
|
87
112
|
export type TranslationRequest = {
|
|
88
113
|
text: string;
|
|
89
114
|
targetLanguage: string;
|
package/dist/tasks-server.js
CHANGED
|
@@ -13,7 +13,8 @@ export class TaskClient {
|
|
|
13
13
|
return this.providers.taskRequest(this.provider, "tasks", route, method, input, this.userToken, signal);
|
|
14
14
|
}
|
|
15
15
|
id(ref) {
|
|
16
|
-
if (ref.appId !== this.provider.appId || ref.installationId !== this.provider.installationId || ref.key !== this.provider.key
|
|
16
|
+
if (ref.appId !== this.provider.appId || ref.installationId !== this.provider.installationId || ref.key !== this.provider.key
|
|
17
|
+
|| (ref.implementationId ?? null) !== (this.provider.implementationId ?? null))
|
|
17
18
|
throw new Error("The task belongs to another provider installation.");
|
|
18
19
|
return encodeURIComponent(ref.id);
|
|
19
20
|
}
|
package/dist/tasks.d.ts
CHANGED
package/dist/tasks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export const taskStatuses = ["Draft", "Ready", "InProgress", "Blocked", "Done", "Cancelled"];
|
|
2
2
|
export const taskExecutionTerminal = (state) => ["completed", "failed", "cancelled", "interrupted"].includes(state);
|
|
3
3
|
/** Collision-free opaque reference for cross-provider links and filters; grants no task access. */
|
|
4
|
-
export const taskReferenceKey = (ref) => JSON.stringify([ref.appId, ref.installationId, ref.key, ref.id]);
|
|
4
|
+
export const taskReferenceKey = (ref) => JSON.stringify(ref.implementationId ? [ref.appId, ref.installationId, ref.key, ref.id, ref.implementationId] : [ref.appId, ref.installationId, ref.key, ref.id]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hosty-sdk/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Hosty app auth: session state machine, recovery bridge, Core revalidation, and the embedder responder.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -157,6 +157,10 @@
|
|
|
157
157
|
"types": "./dist/agent.d.ts",
|
|
158
158
|
"default": "./dist/agent.js"
|
|
159
159
|
},
|
|
160
|
+
"./agent/workflow-tools": {
|
|
161
|
+
"types": "./dist/agent-workflow-tools.d.ts",
|
|
162
|
+
"default": "./dist/agent-workflow-tools.js"
|
|
163
|
+
},
|
|
160
164
|
"./agent/client": {
|
|
161
165
|
"types": "./dist/agent-client.d.ts",
|
|
162
166
|
"default": "./dist/agent-client.js"
|
|
@@ -3129,6 +3129,18 @@
|
|
|
3129
3129
|
"type": "string",
|
|
3130
3130
|
"minLength": 1,
|
|
3131
3131
|
"maxLength": 256
|
|
3132
|
+
},
|
|
3133
|
+
"implementationId": {
|
|
3134
|
+
"anyOf": [
|
|
3135
|
+
{
|
|
3136
|
+
"type": "string",
|
|
3137
|
+
"minLength": 1,
|
|
3138
|
+
"maxLength": 128
|
|
3139
|
+
},
|
|
3140
|
+
{
|
|
3141
|
+
"type": "null"
|
|
3142
|
+
}
|
|
3143
|
+
]
|
|
3132
3144
|
}
|
|
3133
3145
|
},
|
|
3134
3146
|
"required": [
|