@getcliqio/cliq-sdk 0.0.0-stage → 1.15.33
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 +28 -2
- package/dist/agent_api.d.ts +39 -0
- package/dist/agent_api.d.ts.map +1 -0
- package/dist/agent_api.js +105 -0
- package/dist/agent_api.js.map +1 -0
- package/dist/agent_manifest.d.ts +162 -0
- package/dist/agent_manifest.d.ts.map +1 -0
- package/dist/agent_manifest.js +242 -0
- package/dist/agent_manifest.js.map +1 -0
- package/dist/agent_payloads.d.ts +103 -0
- package/dist/agent_payloads.d.ts.map +1 -0
- package/dist/agent_payloads.js +56 -0
- package/dist/agent_payloads.js.map +1 -0
- package/dist/agents/base_agent.d.ts +113 -0
- package/dist/agents/base_agent.d.ts.map +1 -0
- package/dist/agents/base_agent.js +413 -0
- package/dist/agents/base_agent.js.map +1 -0
- package/dist/agents/cli_agent.d.ts +98 -0
- package/dist/agents/cli_agent.d.ts.map +1 -0
- package/dist/agents/cli_agent.js +303 -0
- package/dist/agents/cli_agent.js.map +1 -0
- package/dist/agents/cli_rehydrate.d.ts +29 -0
- package/dist/agents/cli_rehydrate.d.ts.map +1 -0
- package/dist/agents/cli_rehydrate.js +32 -0
- package/dist/agents/cli_rehydrate.js.map +1 -0
- package/dist/agents/connector_agent.d.ts +20 -0
- package/dist/agents/connector_agent.d.ts.map +1 -0
- package/dist/agents/connector_agent.js +110 -0
- package/dist/agents/connector_agent.js.map +1 -0
- package/dist/agents/event_artifacts.d.ts +33 -0
- package/dist/agents/event_artifacts.d.ts.map +1 -0
- package/dist/agents/event_artifacts.js +73 -0
- package/dist/agents/event_artifacts.js.map +1 -0
- package/dist/agents/gate_agent.d.ts +40 -0
- package/dist/agents/gate_agent.d.ts.map +1 -0
- package/dist/agents/gate_agent.js +121 -0
- package/dist/agents/gate_agent.js.map +1 -0
- package/dist/agents/index.d.ts +32 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +26 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/llm_agent.d.ts +109 -0
- package/dist/agents/llm_agent.d.ts.map +1 -0
- package/dist/agents/llm_agent.js +285 -0
- package/dist/agents/llm_agent.js.map +1 -0
- package/dist/agents/llm_contract.d.ts +7 -0
- package/dist/agents/llm_contract.d.ts.map +1 -0
- package/dist/agents/llm_contract.js +7 -0
- package/dist/agents/llm_contract.js.map +1 -0
- package/dist/agents/standard_agent.d.ts +15 -0
- package/dist/agents/standard_agent.d.ts.map +1 -0
- package/dist/agents/standard_agent.js +34 -0
- package/dist/agents/standard_agent.js.map +1 -0
- package/dist/agents/turn_result.d.ts +67 -0
- package/dist/agents/turn_result.d.ts.map +1 -0
- package/dist/agents/turn_result.js +81 -0
- package/dist/agents/turn_result.js.map +1 -0
- package/dist/agents/types.d.ts +314 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +20 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/builtin_teams/hello_hug.d.ts +9 -0
- package/dist/builtin_teams/hello_hug.d.ts.map +1 -0
- package/dist/builtin_teams/hello_hug.js +68 -0
- package/dist/builtin_teams/hello_hug.js.map +1 -0
- package/dist/builtin_teams/hello_world.d.ts +8 -0
- package/dist/builtin_teams/hello_world.d.ts.map +1 -0
- package/dist/builtin_teams/hello_world.js +65 -0
- package/dist/builtin_teams/hello_world.js.map +1 -0
- package/dist/builtin_teams/hug_example.d.ts +10 -0
- package/dist/builtin_teams/hug_example.d.ts.map +1 -0
- package/dist/builtin_teams/hug_example.js +94 -0
- package/dist/builtin_teams/hug_example.js.map +1 -0
- package/dist/builtin_teams/index.d.ts +12 -0
- package/dist/builtin_teams/index.d.ts.map +1 -0
- package/dist/builtin_teams/index.js +18 -0
- package/dist/builtin_teams/index.js.map +1 -0
- package/dist/builtin_teams/types.d.ts +29 -0
- package/dist/builtin_teams/types.d.ts.map +1 -0
- package/dist/builtin_teams/types.js +3 -0
- package/dist/builtin_teams/types.js.map +1 -0
- package/dist/core_api_client.d.ts +48 -0
- package/dist/core_api_client.d.ts.map +1 -0
- package/dist/core_api_client.js +132 -0
- package/dist/core_api_client.js.map +1 -0
- package/dist/daemon_wire.d.ts +122 -0
- package/dist/daemon_wire.d.ts.map +1 -0
- package/dist/daemon_wire.js +105 -0
- package/dist/daemon_wire.js.map +1 -0
- package/dist/events/catalog.d.ts +40 -0
- package/dist/events/catalog.d.ts.map +1 -0
- package/dist/events/catalog.js +76 -0
- package/dist/events/catalog.js.map +1 -0
- package/dist/http_daemon_client.d.ts +136 -0
- package/dist/http_daemon_client.d.ts.map +1 -0
- package/dist/http_daemon_client.js +192 -0
- package/dist/http_daemon_client.js.map +1 -0
- package/dist/hug/ask.d.ts +160 -0
- package/dist/hug/ask.d.ts.map +1 -0
- package/dist/hug/ask.js +318 -0
- package/dist/hug/ask.js.map +1 -0
- package/dist/hug/attach.d.ts +60 -0
- package/dist/hug/attach.d.ts.map +1 -0
- package/dist/hug/attach.js +103 -0
- package/dist/hug/attach.js.map +1 -0
- package/dist/hug/bridge/index.d.ts +16 -0
- package/dist/hug/bridge/index.d.ts.map +1 -0
- package/dist/hug/bridge/index.js +13 -0
- package/dist/hug/bridge/index.js.map +1 -0
- package/dist/hug/bridge/messages.d.ts +559 -0
- package/dist/hug/bridge/messages.d.ts.map +1 -0
- package/dist/hug/bridge/messages.js +165 -0
- package/dist/hug/bridge/messages.js.map +1 -0
- package/dist/hug/client.d.ts +70 -0
- package/dist/hug/client.d.ts.map +1 -0
- package/dist/hug/client.js +144 -0
- package/dist/hug/client.js.map +1 -0
- package/dist/hug/context.d.ts +54 -0
- package/dist/hug/context.d.ts.map +1 -0
- package/dist/hug/context.js +27 -0
- package/dist/hug/context.js.map +1 -0
- package/dist/hug/define.d.ts +116 -0
- package/dist/hug/define.d.ts.map +1 -0
- package/dist/hug/define.js +119 -0
- package/dist/hug/define.js.map +1 -0
- package/dist/hug/definitions/approval.d.ts +216 -0
- package/dist/hug/definitions/approval.d.ts.map +1 -0
- package/dist/hug/definitions/approval.js +50 -0
- package/dist/hug/definitions/approval.js.map +1 -0
- package/dist/hug/definitions/common.d.ts +122 -0
- package/dist/hug/definitions/common.d.ts.map +1 -0
- package/dist/hug/definitions/common.js +70 -0
- package/dist/hug/definitions/common.js.map +1 -0
- package/dist/hug/definitions/form.d.ts +197 -0
- package/dist/hug/definitions/form.d.ts.map +1 -0
- package/dist/hug/definitions/form.js +29 -0
- package/dist/hug/definitions/form.js.map +1 -0
- package/dist/hug/definitions/index.d.ts +10 -0
- package/dist/hug/definitions/index.d.ts.map +1 -0
- package/dist/hug/definitions/index.js +8 -0
- package/dist/hug/definitions/index.js.map +1 -0
- package/dist/hug/errors.d.ts +30 -0
- package/dist/hug/errors.d.ts.map +1 -0
- package/dist/hug/errors.js +46 -0
- package/dist/hug/errors.js.map +1 -0
- package/dist/hug/file_checks.d.ts +41 -0
- package/dist/hug/file_checks.d.ts.map +1 -0
- package/dist/hug/file_checks.js +105 -0
- package/dist/hug/file_checks.js.map +1 -0
- package/dist/hug/files.d.ts +137 -0
- package/dist/hug/files.d.ts.map +1 -0
- package/dist/hug/files.js +283 -0
- package/dist/hug/files.js.map +1 -0
- package/dist/hug/hug_bundle.d.ts +70 -0
- package/dist/hug/hug_bundle.d.ts.map +1 -0
- package/dist/hug/hug_bundle.js +299 -0
- package/dist/hug/hug_bundle.js.map +1 -0
- package/dist/hug/hug_catalog.d.ts +38 -0
- package/dist/hug/hug_catalog.d.ts.map +1 -0
- package/dist/hug/hug_catalog.js +67 -0
- package/dist/hug/hug_catalog.js.map +1 -0
- package/dist/hug/hug_definitions.d.ts +32 -0
- package/dist/hug/hug_definitions.d.ts.map +1 -0
- package/dist/hug/hug_definitions.js +74 -0
- package/dist/hug/hug_definitions.js.map +1 -0
- package/dist/hug/index.d.ts +37 -0
- package/dist/hug/index.d.ts.map +1 -0
- package/dist/hug/index.js +23 -0
- package/dist/hug/index.js.map +1 -0
- package/dist/hug/llm.d.ts +106 -0
- package/dist/hug/llm.d.ts.map +1 -0
- package/dist/hug/llm.js +250 -0
- package/dist/hug/llm.js.map +1 -0
- package/dist/hug/policies.d.ts +65 -0
- package/dist/hug/policies.d.ts.map +1 -0
- package/dist/hug/policies.js +80 -0
- package/dist/hug/policies.js.map +1 -0
- package/dist/hug/problems.d.ts +35 -0
- package/dist/hug/problems.d.ts.map +1 -0
- package/dist/hug/problems.js +53 -0
- package/dist/hug/problems.js.map +1 -0
- package/dist/hug/requested_inputs.d.ts +190 -0
- package/dist/hug/requested_inputs.d.ts.map +1 -0
- package/dist/hug/requested_inputs.js +220 -0
- package/dist/hug/requested_inputs.js.map +1 -0
- package/dist/hug/schema_for_inputs.d.ts +20 -0
- package/dist/hug/schema_for_inputs.d.ts.map +1 -0
- package/dist/hug/schema_for_inputs.js +95 -0
- package/dist/hug/schema_for_inputs.js.map +1 -0
- package/dist/hug/session.d.ts +113 -0
- package/dist/hug/session.d.ts.map +1 -0
- package/dist/hug/session.js +210 -0
- package/dist/hug/session.js.map +1 -0
- package/dist/hug/types.d.ts +141 -0
- package/dist/hug/types.d.ts.map +1 -0
- package/dist/hug/types.js +80 -0
- package/dist/hug/types.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +172 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +306 -0
- package/dist/logging.js.map +1 -0
- package/dist/mcp.d.ts +119 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +259 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mcp_client.d.ts +145 -0
- package/dist/mcp_client.d.ts.map +1 -0
- package/dist/mcp_client.js +374 -0
- package/dist/mcp_client.js.map +1 -0
- package/dist/paths.d.ts +20 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +20 -0
- package/dist/paths.js.map +1 -0
- package/dist/protocol/factory.d.ts +32 -0
- package/dist/protocol/factory.d.ts.map +1 -0
- package/dist/protocol/factory.js +31 -0
- package/dist/protocol/factory.js.map +1 -0
- package/dist/protocol/framing.d.ts +35 -0
- package/dist/protocol/framing.d.ts.map +1 -0
- package/dist/protocol/framing.js +73 -0
- package/dist/protocol/framing.js.map +1 -0
- package/dist/protocol/index.d.ts +13 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +13 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/types/agent.d.ts +42 -0
- package/dist/protocol/types/agent.d.ts.map +1 -0
- package/dist/protocol/types/agent.js +9 -0
- package/dist/protocol/types/agent.js.map +1 -0
- package/dist/protocol/types/cliq_core.d.ts +79 -0
- package/dist/protocol/types/cliq_core.d.ts.map +1 -0
- package/dist/protocol/types/cliq_core.js +17 -0
- package/dist/protocol/types/cliq_core.js.map +1 -0
- package/dist/protocol/types/foundations.d.ts +41 -0
- package/dist/protocol/types/foundations.d.ts.map +1 -0
- package/dist/protocol/types/foundations.js +10 -0
- package/dist/protocol/types/foundations.js.map +1 -0
- package/dist/protocol/types/index.d.ts +32 -0
- package/dist/protocol/types/index.d.ts.map +1 -0
- package/dist/protocol/types/index.js +27 -0
- package/dist/protocol/types/index.js.map +1 -0
- package/dist/protocol/types/messages.d.ts +827 -0
- package/dist/protocol/types/messages.d.ts.map +1 -0
- package/dist/protocol/types/messages.js +117 -0
- package/dist/protocol/types/messages.js.map +1 -0
- package/dist/protocol/types/pipeline.d.ts +122 -0
- package/dist/protocol/types/pipeline.d.ts.map +1 -0
- package/dist/protocol/types/pipeline.js +16 -0
- package/dist/protocol/types/pipeline.js.map +1 -0
- package/dist/protocol/types/schemas.d.ts +814 -0
- package/dist/protocol/types/schemas.d.ts.map +1 -0
- package/dist/protocol/types/schemas.js +772 -0
- package/dist/protocol/types/schemas.js.map +1 -0
- package/dist/protocol/types/team.d.ts +42 -0
- package/dist/protocol/types/team.d.ts.map +1 -0
- package/dist/protocol/types/team.js +15 -0
- package/dist/protocol/types/team.js.map +1 -0
- package/dist/protocol/types/workspace.d.ts +46 -0
- package/dist/protocol/types/workspace.d.ts.map +1 -0
- package/dist/protocol/types/workspace.js +9 -0
- package/dist/protocol/types/workspace.js.map +1 -0
- package/dist/settings_keys.d.ts +12 -0
- package/dist/settings_keys.d.ts.map +1 -0
- package/dist/settings_keys.js +35 -0
- package/dist/settings_keys.js.map +1 -0
- package/dist/tcp/client.d.ts +15 -0
- package/dist/tcp/client.d.ts.map +1 -0
- package/dist/tcp/client.js +28 -0
- package/dist/tcp/client.js.map +1 -0
- package/dist/tcp/connection.d.ts +79 -0
- package/dist/tcp/connection.d.ts.map +1 -0
- package/dist/tcp/connection.js +153 -0
- package/dist/tcp/connection.js.map +1 -0
- package/dist/tcp/index.d.ts +10 -0
- package/dist/tcp/index.d.ts.map +1 -0
- package/dist/tcp/index.js +7 -0
- package/dist/tcp/index.js.map +1 -0
- package/dist/tcp/server.d.ts +31 -0
- package/dist/tcp/server.d.ts.map +1 -0
- package/dist/tcp/server.js +54 -0
- package/dist/tcp/server.js.map +1 -0
- package/dist/team/bundle.d.ts +88 -0
- package/dist/team/bundle.d.ts.map +1 -0
- package/dist/team/bundle.js +214 -0
- package/dist/team/bundle.js.map +1 -0
- package/dist/team/identity.d.ts +31 -0
- package/dist/team/identity.d.ts.map +1 -0
- package/dist/team/identity.js +83 -0
- package/dist/team/identity.js.map +1 -0
- package/dist/team/index.d.ts +13 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/index.js +8 -0
- package/dist/team/index.js.map +1 -0
- package/dist/team/lint_bundle.d.ts +16 -0
- package/dist/team/lint_bundle.d.ts.map +1 -0
- package/dist/team/lint_bundle.js +35 -0
- package/dist/team/lint_bundle.js.map +1 -0
- package/dist/team/ref.d.ts +48 -0
- package/dist/team/ref.d.ts.map +1 -0
- package/dist/team/ref.js +70 -0
- package/dist/team/ref.js.map +1 -0
- package/dist/team/roles.d.ts +22 -0
- package/dist/team/roles.d.ts.map +1 -0
- package/dist/team/roles.js +33 -0
- package/dist/team/roles.js.map +1 -0
- package/dist/team/tree.d.ts +101 -0
- package/dist/team/tree.d.ts.map +1 -0
- package/dist/team/tree.js +125 -0
- package/dist/team/tree.js.map +1 -0
- package/dist/team_lint.d.ts +57 -0
- package/dist/team_lint.d.ts.map +1 -0
- package/dist/team_lint.js +277 -0
- package/dist/team_lint.js.map +1 -0
- package/dist/telemetry/stream_json_usage.d.ts +39 -0
- package/dist/telemetry/stream_json_usage.d.ts.map +1 -0
- package/dist/telemetry/stream_json_usage.js +139 -0
- package/dist/telemetry/stream_json_usage.js.map +1 -0
- package/dist/telemetry/usage.d.ts +288 -0
- package/dist/telemetry/usage.d.ts.map +1 -0
- package/dist/telemetry/usage.js +421 -0
- package/dist/telemetry/usage.js.map +1 -0
- package/dist/utils/duration.d.ts +11 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/duration.js +22 -0
- package/dist/utils/duration.js.map +1 -0
- package/dist/utils/redact.d.ts +26 -0
- package/dist/utils/redact.d.ts.map +1 -0
- package/dist/utils/redact.js +52 -0
- package/dist/utils/redact.js.map +1 -0
- package/dist/utils/url.d.ts +6 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +11 -0
- package/dist/utils/url.js.map +1 -0
- package/package.json +72 -5
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cliqd wire contract — the only request / reply shape the daemon's
|
|
3
|
+
* HTTP API has (cliq-sdk 2.0):
|
|
4
|
+
*
|
|
5
|
+
* request the route's plain input object as the JSON body
|
|
6
|
+
* success `{ ok: true, data }`
|
|
7
|
+
* failure `{ ok: false, error: { code, message, details? } }` with a 4xx / 5xx status
|
|
8
|
+
*
|
|
9
|
+
* Run outcomes are successes with `data.status` (see {@link RunOutcome} and
|
|
10
|
+
* {@link InitOutcome}).
|
|
11
|
+
*
|
|
12
|
+
* {@link read_daemon_reply} reads a reply; {@link post_daemon} is the bare
|
|
13
|
+
* POST the agent-side helpers use (`HttpDaemonClient.call()` adds auth,
|
|
14
|
+
* route names and token refresh for the CLI).
|
|
15
|
+
*/
|
|
16
|
+
import type { InitResult } from './protocol/types/workspace.js';
|
|
17
|
+
/** The `error` object of a failure reply. */
|
|
18
|
+
export interface DaemonErrorBody {
|
|
19
|
+
/** Stable error code (`RUN_NOT_FOUND`, `PAYLOAD_INVALID`, …). */
|
|
20
|
+
readonly code: string;
|
|
21
|
+
/** Human-readable message. */
|
|
22
|
+
readonly message: string;
|
|
23
|
+
/** Structured detail (validation issues, …), when any. */
|
|
24
|
+
readonly details?: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** A reply body. */
|
|
27
|
+
export type DaemonReply<T = unknown> = {
|
|
28
|
+
readonly ok: true;
|
|
29
|
+
readonly data: T;
|
|
30
|
+
} | {
|
|
31
|
+
readonly ok: false;
|
|
32
|
+
readonly error: DaemonErrorBody;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* cliqd answered, but not with success: a failure reply, a non-2xx
|
|
36
|
+
* status, or a body that is not a cliqd reply (`code: 'BAD_RESPONSE'`).
|
|
37
|
+
* Distinct from `DaemonUnreachableError`, which means it did not answer.
|
|
38
|
+
*/
|
|
39
|
+
export declare class DaemonError extends Error {
|
|
40
|
+
/** HTTP status of the reply. */
|
|
41
|
+
readonly status: number;
|
|
42
|
+
/** Stable error code. */
|
|
43
|
+
readonly code: string;
|
|
44
|
+
/** Structured detail, when any. */
|
|
45
|
+
readonly details: unknown;
|
|
46
|
+
/** `x-request-id` of the call, for correlating with daemon logs. */
|
|
47
|
+
readonly request_id: string | null;
|
|
48
|
+
constructor(status: number, body: DaemonErrorBody, request_id?: string | null);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Reads a cliqd reply: the `data` of a success, or a thrown {@link DaemonError}.
|
|
52
|
+
*
|
|
53
|
+
* @param status - HTTP status.
|
|
54
|
+
* @param text - Raw body.
|
|
55
|
+
* @param request_id - `x-request-id` of the call.
|
|
56
|
+
* @throws DaemonError on any failure or unreadable body.
|
|
57
|
+
*/
|
|
58
|
+
export declare function read_daemon_reply<T = unknown>(status: number, text: string, request_id?: string | null): T;
|
|
59
|
+
/** Options of {@link post_daemon}. */
|
|
60
|
+
export interface PostDaemonOptions {
|
|
61
|
+
/** Abort after this many milliseconds. */
|
|
62
|
+
readonly timeout_ms?: number;
|
|
63
|
+
/** Extra headers (e.g. `Authorization`). */
|
|
64
|
+
readonly headers?: Record<string, string>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* POSTs a plain input to a daemon route and resolves with the reply's `data`.
|
|
68
|
+
*
|
|
69
|
+
* @param daemon_url - Base URL, e.g. `http://127.0.0.1:4900` (no trailing slash needed).
|
|
70
|
+
* @param path - Route path, e.g. `/v1/hugs/next`.
|
|
71
|
+
* @param input - The route's input.
|
|
72
|
+
* @throws DaemonError when cliqd answered with a failure; the transport error when it did not answer.
|
|
73
|
+
*/
|
|
74
|
+
export declare function post_daemon<T = unknown>(daemon_url: string, path: string, input: unknown, options?: PostDaemonOptions): Promise<T>;
|
|
75
|
+
/** `run` started (or was already running for this idempotency key). */
|
|
76
|
+
export interface RunStarted {
|
|
77
|
+
readonly status: 'started';
|
|
78
|
+
readonly run_id: string;
|
|
79
|
+
readonly run_name: string;
|
|
80
|
+
readonly instance_id: string;
|
|
81
|
+
readonly workspace_dir: string;
|
|
82
|
+
readonly idempotent?: boolean;
|
|
83
|
+
/** Things to tell the person, e.g. that this run won't appear in CliqHub (its team isn't in the realm). */
|
|
84
|
+
readonly warnings?: readonly string[];
|
|
85
|
+
}
|
|
86
|
+
/** `run` needs inputs before its first phase can start. */
|
|
87
|
+
export interface RunInputsRequired {
|
|
88
|
+
readonly status: 'inputs_required';
|
|
89
|
+
readonly phase: string;
|
|
90
|
+
readonly missing_inputs: ReadonlyArray<{
|
|
91
|
+
name: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
required?: boolean;
|
|
94
|
+
agent: string;
|
|
95
|
+
}>;
|
|
96
|
+
}
|
|
97
|
+
/** `run` found agents that are missing or not configured. */
|
|
98
|
+
export interface RunAgentNotReady {
|
|
99
|
+
readonly status: 'agent_not_ready';
|
|
100
|
+
readonly agents: ReadonlyArray<{
|
|
101
|
+
name: string;
|
|
102
|
+
issues?: string[];
|
|
103
|
+
setup_hint?: string;
|
|
104
|
+
}>;
|
|
105
|
+
}
|
|
106
|
+
/** `data` of `POST /v1/workspaces/run`. */
|
|
107
|
+
export type RunOutcome = RunStarted | RunInputsRequired | RunAgentNotReady;
|
|
108
|
+
/** `data` of `POST /v1/workspaces/init`: the workspace, or the fields to ask for. */
|
|
109
|
+
export type InitOutcome = ({
|
|
110
|
+
readonly status: 'initialized';
|
|
111
|
+
} & InitResult) | {
|
|
112
|
+
readonly status: 'input_required';
|
|
113
|
+
readonly inputs: ReadonlyArray<InitInputField>;
|
|
114
|
+
};
|
|
115
|
+
/** A field `init` needs before it can register the workspace. */
|
|
116
|
+
export interface InitInputField {
|
|
117
|
+
readonly field: string;
|
|
118
|
+
readonly label: string;
|
|
119
|
+
readonly input_type: string;
|
|
120
|
+
readonly options?: string[];
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=daemon_wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon_wire.d.ts","sourceRoot":"","sources":["../src/daemon_wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,oBAAoB;AACpB,MAAM,MAAM,WAAW,CAA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AE,aAAa,CAAC,cAAc,CAAC,CAAA;CAAE,CAAC;AAE5F,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cliqd wire contract — the only request / reply shape the daemon's
|
|
3
|
+
* HTTP API has (cliq-sdk 2.0):
|
|
4
|
+
*
|
|
5
|
+
* request the route's plain input object as the JSON body
|
|
6
|
+
* success `{ ok: true, data }`
|
|
7
|
+
* failure `{ ok: false, error: { code, message, details? } }` with a 4xx / 5xx status
|
|
8
|
+
*
|
|
9
|
+
* Run outcomes are successes with `data.status` (see {@link RunOutcome} and
|
|
10
|
+
* {@link InitOutcome}).
|
|
11
|
+
*
|
|
12
|
+
* {@link read_daemon_reply} reads a reply; {@link post_daemon} is the bare
|
|
13
|
+
* POST the agent-side helpers use (`HttpDaemonClient.call()` adds auth,
|
|
14
|
+
* route names and token refresh for the CLI).
|
|
15
|
+
*/
|
|
16
|
+
import { strip_trailing_slashes } from './utils/url.js';
|
|
17
|
+
/**
|
|
18
|
+
* cliqd answered, but not with success: a failure reply, a non-2xx
|
|
19
|
+
* status, or a body that is not a cliqd reply (`code: 'BAD_RESPONSE'`).
|
|
20
|
+
* Distinct from `DaemonUnreachableError`, which means it did not answer.
|
|
21
|
+
*/
|
|
22
|
+
export class DaemonError extends Error {
|
|
23
|
+
/** HTTP status of the reply. */
|
|
24
|
+
status;
|
|
25
|
+
/** Stable error code. */
|
|
26
|
+
code;
|
|
27
|
+
/** Structured detail, when any. */
|
|
28
|
+
details;
|
|
29
|
+
/** `x-request-id` of the call, for correlating with daemon logs. */
|
|
30
|
+
request_id;
|
|
31
|
+
constructor(status, body, request_id = null) {
|
|
32
|
+
super(body.message);
|
|
33
|
+
this.name = 'DaemonError';
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.code = body.code;
|
|
36
|
+
this.details = body.details;
|
|
37
|
+
this.request_id = request_id;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** True for a plain (non-array) object. */
|
|
41
|
+
function _is_record(value) {
|
|
42
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
43
|
+
}
|
|
44
|
+
/** The `{ code, message, details }` of a failure body, if it is one. */
|
|
45
|
+
function _error_body(body) {
|
|
46
|
+
const candidate = body.ok === false ? body.error : null;
|
|
47
|
+
if (!_is_record(candidate))
|
|
48
|
+
return null;
|
|
49
|
+
if (typeof candidate.code !== 'string' || typeof candidate.message !== 'string')
|
|
50
|
+
return null;
|
|
51
|
+
return {
|
|
52
|
+
code: candidate.code,
|
|
53
|
+
message: candidate.message,
|
|
54
|
+
...(candidate.details === undefined ? {} : { details: candidate.details }),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reads a cliqd reply: the `data` of a success, or a thrown {@link DaemonError}.
|
|
59
|
+
*
|
|
60
|
+
* @param status - HTTP status.
|
|
61
|
+
* @param text - Raw body.
|
|
62
|
+
* @param request_id - `x-request-id` of the call.
|
|
63
|
+
* @throws DaemonError on any failure or unreadable body.
|
|
64
|
+
*/
|
|
65
|
+
export function read_daemon_reply(status, text, request_id = null) {
|
|
66
|
+
let body;
|
|
67
|
+
try {
|
|
68
|
+
body = JSON.parse(text);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
throw new DaemonError(status, {
|
|
72
|
+
code: 'BAD_RESPONSE',
|
|
73
|
+
message: `cliqd returned a non-JSON response (HTTP ${status}): ${text.slice(0, 200)}`,
|
|
74
|
+
}, request_id);
|
|
75
|
+
}
|
|
76
|
+
if (_is_record(body)) {
|
|
77
|
+
const error = _error_body(body);
|
|
78
|
+
if (error)
|
|
79
|
+
throw new DaemonError(status, error, request_id);
|
|
80
|
+
if (body.ok === true && status >= 200 && status < 300)
|
|
81
|
+
return body.data;
|
|
82
|
+
}
|
|
83
|
+
throw new DaemonError(status, {
|
|
84
|
+
code: 'BAD_RESPONSE',
|
|
85
|
+
message: `cliqd returned an unexpected reply (HTTP ${status}) — is it older than this client?`,
|
|
86
|
+
}, request_id);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* POSTs a plain input to a daemon route and resolves with the reply's `data`.
|
|
90
|
+
*
|
|
91
|
+
* @param daemon_url - Base URL, e.g. `http://127.0.0.1:4900` (no trailing slash needed).
|
|
92
|
+
* @param path - Route path, e.g. `/v1/hugs/next`.
|
|
93
|
+
* @param input - The route's input.
|
|
94
|
+
* @throws DaemonError when cliqd answered with a failure; the transport error when it did not answer.
|
|
95
|
+
*/
|
|
96
|
+
export async function post_daemon(daemon_url, path, input, options = {}) {
|
|
97
|
+
const res = await fetch(`${strip_trailing_slashes(daemon_url)}${path}`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: { 'Content-Type': 'application/json', ...(options.headers ?? {}) },
|
|
100
|
+
body: JSON.stringify(input ?? {}),
|
|
101
|
+
...(options.timeout_ms ? { signal: AbortSignal.timeout(options.timeout_ms) } : {}),
|
|
102
|
+
});
|
|
103
|
+
return read_daemon_reply(res.status, await res.text(), res.headers?.get?.('x-request-id') ?? null);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=daemon_wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon_wire.js","sourceRoot":"","sources":["../src/daemon_wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAiBxD;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClC,gCAAgC;IACvB,MAAM,CAAS;IACxB,yBAAyB;IAChB,IAAI,CAA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AC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrF,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC;AAC1G,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle event catalog — shared namespaced event types for daemon,
|
|
3
|
+
* Hub, team `notify`, and docs (`{domain}.{verb}`).
|
|
4
|
+
*
|
|
5
|
+
* Yamazaki: one vocabulary everywhere. No underscored aliases and no
|
|
6
|
+
* `on_*` notify hooks. Keep this list aligned with Hub `EVENT_TYPES`
|
|
7
|
+
* for the run/phase/hug overlap; Hub may have additional org/daemon
|
|
8
|
+
* types that never originate from a local run executor.
|
|
9
|
+
*
|
|
10
|
+
* @see design/yamazaki/DEFAULTS.md
|
|
11
|
+
* @see design/yamazaki/LLD.md (P0.1)
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Run + phase + Hug events the daemon publishes to Hub's event catalog (notification rules match
|
|
15
|
+
* them). Equal to Hub `EVENT_TYPES` for the run / phase / hug overlap. `phase.waiting` and
|
|
16
|
+
* `hug.opened` are run-stream events only: Core learns a wait from the activity stream, and posts a
|
|
17
|
+
* new Hug straight to its channels (PLAN-hug-requests §6.8, §15).
|
|
18
|
+
*/
|
|
19
|
+
export declare const LIFECYCLE_EVENTS: readonly ["run.started", "run.resumed", "run.completed", "run.failed", "run.crashed", "run.cancelled", "phase.started", "phase.completed", "phase.failed", "phase.skipped", "phase.escalated", "phase.resumed", "phase.timed_out", "phase.idle", "hug.reminded", "hug.responded", "hug.closed", "hug.expired"];
|
|
20
|
+
/** A run/phase/HUG lifecycle event name. */
|
|
21
|
+
export type LifecycleEvent = (typeof LIFECYCLE_EVENTS)[number];
|
|
22
|
+
/**
|
|
23
|
+
* Events that Hub delivers to `realm:all_users` when team/phase notify
|
|
24
|
+
* is omitted or `[]` (explicit `false` mutes). Daemon does not resolve
|
|
25
|
+
* the all-users channel — Hub does.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DEFAULT_NOTIFY_EVENTS: readonly ["phase.idle", "phase.timed_out", "run.failed", "run.crashed"];
|
|
28
|
+
/** An event Hub notifies all realm users of by default. */
|
|
29
|
+
export type DefaultNotifyEvent = (typeof DEFAULT_NOTIFY_EVENTS)[number];
|
|
30
|
+
/** High-volume agent stream events (transcript); not default-notify. */
|
|
31
|
+
export declare const AGENT_STREAM_EVENTS: readonly ["agent.started", "agent.progress", "agent.thinking", "agent.assistant_message", "agent.tool_call", "agent.tool_result", "agent.log", "agent.warning", "agent.usage"];
|
|
32
|
+
/** An agent transcript stream event name. */
|
|
33
|
+
export type AgentStreamEvent = (typeof AGENT_STREAM_EVENTS)[number];
|
|
34
|
+
/** True for a name in {@link LIFECYCLE_EVENTS}. */
|
|
35
|
+
export declare function is_lifecycle_event(value: string): value is LifecycleEvent;
|
|
36
|
+
/** True for a name in {@link DEFAULT_NOTIFY_EVENTS}. */
|
|
37
|
+
export declare function is_default_notify_event(value: string): value is DefaultNotifyEvent;
|
|
38
|
+
/** True for `custom.*` team-declared / agent-emitted extras. */
|
|
39
|
+
export declare function is_custom_event(value: string): boolean;
|
|
40
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/events/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,gTAmBnB,CAAC;AAEX,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI/D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,yEAKxB,CAAC;AAEX,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAIxE,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,gLAUtB,CAAC;AAEX,6CAA6C;AAC7C,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAEzE;AAED,wDAAwD;AACxD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,kBAAkB,CAElF;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle event catalog — shared namespaced event types for daemon,
|
|
3
|
+
* Hub, team `notify`, and docs (`{domain}.{verb}`).
|
|
4
|
+
*
|
|
5
|
+
* Yamazaki: one vocabulary everywhere. No underscored aliases and no
|
|
6
|
+
* `on_*` notify hooks. Keep this list aligned with Hub `EVENT_TYPES`
|
|
7
|
+
* for the run/phase/hug overlap; Hub may have additional org/daemon
|
|
8
|
+
* types that never originate from a local run executor.
|
|
9
|
+
*
|
|
10
|
+
* @see design/yamazaki/DEFAULTS.md
|
|
11
|
+
* @see design/yamazaki/LLD.md (P0.1)
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Run + phase + Hug events the daemon publishes to Hub's event catalog (notification rules match
|
|
15
|
+
* them). Equal to Hub `EVENT_TYPES` for the run / phase / hug overlap. `phase.waiting` and
|
|
16
|
+
* `hug.opened` are run-stream events only: Core learns a wait from the activity stream, and posts a
|
|
17
|
+
* new Hug straight to its channels (PLAN-hug-requests §6.8, §15).
|
|
18
|
+
*/
|
|
19
|
+
export const LIFECYCLE_EVENTS = [
|
|
20
|
+
'run.started',
|
|
21
|
+
'run.resumed',
|
|
22
|
+
'run.completed',
|
|
23
|
+
'run.failed',
|
|
24
|
+
'run.crashed',
|
|
25
|
+
'run.cancelled',
|
|
26
|
+
'phase.started',
|
|
27
|
+
'phase.completed',
|
|
28
|
+
'phase.failed',
|
|
29
|
+
'phase.skipped',
|
|
30
|
+
'phase.escalated',
|
|
31
|
+
'phase.resumed',
|
|
32
|
+
'phase.timed_out',
|
|
33
|
+
'phase.idle',
|
|
34
|
+
'hug.reminded',
|
|
35
|
+
'hug.responded',
|
|
36
|
+
'hug.closed',
|
|
37
|
+
'hug.expired',
|
|
38
|
+
];
|
|
39
|
+
const LIFECYCLE_SET = new Set(LIFECYCLE_EVENTS);
|
|
40
|
+
/**
|
|
41
|
+
* Events that Hub delivers to `realm:all_users` when team/phase notify
|
|
42
|
+
* is omitted or `[]` (explicit `false` mutes). Daemon does not resolve
|
|
43
|
+
* the all-users channel — Hub does.
|
|
44
|
+
*/
|
|
45
|
+
export const DEFAULT_NOTIFY_EVENTS = [
|
|
46
|
+
'phase.idle',
|
|
47
|
+
'phase.timed_out',
|
|
48
|
+
'run.failed',
|
|
49
|
+
'run.crashed',
|
|
50
|
+
];
|
|
51
|
+
const DEFAULT_NOTIFY_SET = new Set(DEFAULT_NOTIFY_EVENTS);
|
|
52
|
+
/** High-volume agent stream events (transcript); not default-notify. */
|
|
53
|
+
export const AGENT_STREAM_EVENTS = [
|
|
54
|
+
'agent.started',
|
|
55
|
+
'agent.progress',
|
|
56
|
+
'agent.thinking',
|
|
57
|
+
'agent.assistant_message',
|
|
58
|
+
'agent.tool_call',
|
|
59
|
+
'agent.tool_result',
|
|
60
|
+
'agent.log',
|
|
61
|
+
'agent.warning',
|
|
62
|
+
'agent.usage',
|
|
63
|
+
];
|
|
64
|
+
/** True for a name in {@link LIFECYCLE_EVENTS}. */
|
|
65
|
+
export function is_lifecycle_event(value) {
|
|
66
|
+
return LIFECYCLE_SET.has(value);
|
|
67
|
+
}
|
|
68
|
+
/** True for a name in {@link DEFAULT_NOTIFY_EVENTS}. */
|
|
69
|
+
export function is_default_notify_event(value) {
|
|
70
|
+
return DEFAULT_NOTIFY_SET.has(value);
|
|
71
|
+
}
|
|
72
|
+
/** True for `custom.*` team-declared / agent-emitted extras. */
|
|
73
|
+
export function is_custom_event(value) {
|
|
74
|
+
return /^custom\..+/.test(value);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/events/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,aAAa;IACb,aAAa;IACb,eAAe;IACf,YAAY;IACZ,aAAa;IACb,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,cAAc;IACd,eAAe;IACf,iBAAiB;IACjB,eAAe;IACf,iBAAiB;IACjB,YAAY;IACZ,cAAc;IACd,eAAe;IACf,YAAY;IACZ,aAAa;CACJ,CAAC;AAKX,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,YAAY;IACZ,iBAAiB;IACjB,YAAY;IACZ,aAAa;CACJ,CAAC;AAKX,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAE/E,wEAAwE;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,iBAAiB;IACjB,mBAAmB;IACnB,WAAW;IACX,eAAe;IACf,aAAa;CACJ,CAAC;AAKX,mDAAmD;AACnD,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC/C,OAAO,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACpD,OAAO,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the cliq daemon (the CLI's view of its API).
|
|
3
|
+
*
|
|
4
|
+
* `call(route, input)` POSTs the route's plain input and resolves with the
|
|
5
|
+
* reply's `data` (`daemon_wire.ts`). It throws:
|
|
6
|
+
*
|
|
7
|
+
* - `DaemonError` when cliqd answered with a failure (`{ ok: false,
|
|
8
|
+
* error: { code, message, details } }`, any non-2xx, or a body that is
|
|
9
|
+
* not a cliqd reply) — `status`, `code`, `details`, `request_id`;
|
|
10
|
+
* - `DaemonUnreachableError` when it did not answer (connection refused,
|
|
11
|
+
* DNS failure, timeout), with the original error on `cause`.
|
|
12
|
+
*
|
|
13
|
+
* The target is a route name (`team_list` → `/v1/teams/get`, see
|
|
14
|
+
* {@link DAEMON_ROUTES}) or a route path (`/v1/runs/logs`).
|
|
15
|
+
*
|
|
16
|
+
* Auth: when a token is supplied it rides in the `Authorization`
|
|
17
|
+
* header as `Bearer <token>` — never in the payload. An UNAUTHORIZED
|
|
18
|
+
* reply triggers one token refresh and retry.
|
|
19
|
+
*/
|
|
20
|
+
/** Route names → daemon route paths. */
|
|
21
|
+
export declare const DAEMON_ROUTES: {
|
|
22
|
+
readonly init: "/v1/workspaces/init";
|
|
23
|
+
readonly assemble_team: "/v1/workspaces/assemble_team";
|
|
24
|
+
readonly workspace_remove_team: "/v1/workspaces/remove_team";
|
|
25
|
+
readonly run: "/v1/workspaces/run";
|
|
26
|
+
readonly status: "/v1/workspaces/status";
|
|
27
|
+
readonly workspace_list: "/v1/workspaces/get";
|
|
28
|
+
readonly clean: "/v1/workspaces/clean";
|
|
29
|
+
readonly remove: "/v1/workspaces/remove";
|
|
30
|
+
readonly doctor: "/v1/workspaces/doctor";
|
|
31
|
+
readonly settings_get: "/v1/settings/get_by_key";
|
|
32
|
+
readonly settings_set: "/v1/settings/set";
|
|
33
|
+
readonly settings_list: "/v1/settings/get";
|
|
34
|
+
readonly team_install: "/v1/teams/install";
|
|
35
|
+
readonly team_uninstall: "/v1/teams/uninstall";
|
|
36
|
+
readonly team_list: "/v1/teams/get";
|
|
37
|
+
readonly team_search: "/v1/teams/search";
|
|
38
|
+
readonly team_info: "/v1/teams/get_by_name";
|
|
39
|
+
readonly team_update: "/v1/teams/update";
|
|
40
|
+
readonly team_publish: "/v1/teams/publish";
|
|
41
|
+
readonly team_validate: "/v1/teams/validate";
|
|
42
|
+
readonly team_hub_install: "/v1/teams/hub_install";
|
|
43
|
+
readonly agent_list: "/v1/agents/get";
|
|
44
|
+
readonly agent_get_by_id: "/v1/agents/get_by_id";
|
|
45
|
+
readonly agent_register: "/v1/agents/register";
|
|
46
|
+
readonly agent_unregister: "/v1/agents/unregister";
|
|
47
|
+
readonly instance_list: "/v1/instances/get";
|
|
48
|
+
readonly instance_info: "/v1/instances/get_by_id";
|
|
49
|
+
readonly instance_kill: "/v1/instances/stop";
|
|
50
|
+
readonly daemon_status: "/v1/daemon/status";
|
|
51
|
+
readonly hub_login: "/v1/login";
|
|
52
|
+
readonly hub_logout: "/v1/logout";
|
|
53
|
+
readonly hub_token: "/v1/auth/token";
|
|
54
|
+
readonly hub_rotate_dispatch: "/v1/auth/rotate_dispatch";
|
|
55
|
+
readonly token_create: "/v1/tokens/create";
|
|
56
|
+
readonly token_list: "/v1/tokens/get";
|
|
57
|
+
readonly token_revoke: "/v1/tokens/revoke";
|
|
58
|
+
readonly resume_run: "/v1/runs/resume";
|
|
59
|
+
readonly run_list: "/v1/runs/get";
|
|
60
|
+
readonly runs_tree: "/v1/runs/tree";
|
|
61
|
+
readonly hugs_next: "/v1/hugs/next";
|
|
62
|
+
readonly hugs_respond: "/v1/hugs/respond";
|
|
63
|
+
readonly hugs_dev: "/v1/hugs/dev";
|
|
64
|
+
};
|
|
65
|
+
/** A route name in {@link DAEMON_ROUTES}. */
|
|
66
|
+
export type DaemonRouteName = keyof typeof DAEMON_ROUTES;
|
|
67
|
+
/** Where the local cliqd listens and how to authenticate to it. */
|
|
68
|
+
export type HttpDaemonClientOptions = {
|
|
69
|
+
/** Daemon host. Defaults to `127.0.0.1`. */
|
|
70
|
+
host?: string;
|
|
71
|
+
/** Daemon port. Defaults to `4900`. */
|
|
72
|
+
port?: number;
|
|
73
|
+
/** Per-request timeout in milliseconds. Defaults to `30000`. */
|
|
74
|
+
timeout_ms?: number;
|
|
75
|
+
/** Bearer token sent in the `Authorization` header (optional). */
|
|
76
|
+
token?: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Async token source (e.g. mint from Core API). Used when `token` is
|
|
79
|
+
* unset, and to refresh once after an UNAUTHORIZED daemon reply.
|
|
80
|
+
*/
|
|
81
|
+
token_provider?: () => Promise<string | null>;
|
|
82
|
+
};
|
|
83
|
+
/** Options of {@link HttpDaemonClient.call}. */
|
|
84
|
+
export type CallOptions = {
|
|
85
|
+
/** Override the client default for this call. */
|
|
86
|
+
timeout_ms?: number;
|
|
87
|
+
};
|
|
88
|
+
/** What {@link HttpDaemonClient.call} targets: a route name, or a route path. */
|
|
89
|
+
export type DaemonCallTarget = DaemonRouteName | `/${string}`;
|
|
90
|
+
/**
|
|
91
|
+
* Raised when the daemon could not be reached at all (connection
|
|
92
|
+
* refused, DNS failure, or timeout) — distinct from an `error`
|
|
93
|
+
* envelope, which means the daemon answered. The original error is
|
|
94
|
+
* preserved on `cause` so callers can branch on `ECONNREFUSED`.
|
|
95
|
+
*/
|
|
96
|
+
export declare class DaemonUnreachableError extends Error {
|
|
97
|
+
readonly url: string;
|
|
98
|
+
readonly request_id: string | null;
|
|
99
|
+
constructor(url: string, cause: unknown, request_id?: string | null);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Client for the local cliqd HTTP API (`http://<host>:<port>`). Every call is a
|
|
103
|
+
* POST of a plain input that resolves with the reply's `data`; one retry after
|
|
104
|
+
* an UNAUTHORIZED reply when a `token_provider` can mint a fresh token.
|
|
105
|
+
*/
|
|
106
|
+
export declare class HttpDaemonClient {
|
|
107
|
+
private readonly base_url;
|
|
108
|
+
private readonly timeout_ms;
|
|
109
|
+
private token;
|
|
110
|
+
private readonly token_provider;
|
|
111
|
+
private _last_request_id;
|
|
112
|
+
constructor(options?: HttpDaemonClientOptions);
|
|
113
|
+
/** Most recent outbound `x-request-id` (for correlating with daemon logs). */
|
|
114
|
+
get last_request_id(): string | null;
|
|
115
|
+
/** Factory mirror of the constructor for call-site symmetry. */
|
|
116
|
+
static create(options?: HttpDaemonClientOptions): HttpDaemonClient;
|
|
117
|
+
/** The daemon route path of a route name. */
|
|
118
|
+
static route_for(name: DaemonRouteName): string;
|
|
119
|
+
/** The route path for a call target (a path is returned as-is). */
|
|
120
|
+
static path_for(target: DaemonCallTarget): string;
|
|
121
|
+
/**
|
|
122
|
+
* POST `input` to the target's route and resolve with the reply's `data`.
|
|
123
|
+
*
|
|
124
|
+
* @param target - Route name (`team_list`) or route path (`/v1/runs/logs`).
|
|
125
|
+
* @param input - The route's plain input object (default `{}`).
|
|
126
|
+
* @param options - Per-call timeout.
|
|
127
|
+
* @throws DaemonError when cliqd answered with a failure; DaemonUnreachableError when it did not answer.
|
|
128
|
+
*/
|
|
129
|
+
call<T = unknown>(target: DaemonCallTarget, input?: unknown, options?: CallOptions): Promise<T>;
|
|
130
|
+
/** One POST of the plain input (see {@link call}). */
|
|
131
|
+
private _call_once;
|
|
132
|
+
private _ensure_token;
|
|
133
|
+
/** Build request headers, adding the bearer token when present. */
|
|
134
|
+
private _headers;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=http_daemon_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http_daemon_client.d.ts","sourceRoot":"","sources":["../src/http_daemon_client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,wCAAwC;AACxC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDhB,CAAC;AAEX,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,aAAa,CAAC;AAEzD,mEAAmE;AACnE,MAAM,MAAM,uBAAuB,GAAG;IAClC,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACjD,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG;IACtB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,IAAI,MAAM,EAAE,CAAC;AAE9D;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEvB,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,GAAE,MAAM,GAAG,IAAW;CAQ5E;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