Files
pipelines/web/src/protocol.js
T
alan 3d98c60de6 Merge branch 'main' into web-search
# Conflicts:
#	web/src/app.js
#	web/src/protocol.js
#	web/src/repository.js
#	web/styles.css
#	web/test/repository.test.mjs
#	web/test/ui-smoke.mjs
2026-10-19 04:44:54 +01:00

59 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Protocol command/type constants. Mirrors the subset of
// android/app/src/main/java/net/awan/pipelines/data/protocol/Message.kt and
// internal/protocol/*.go used by this spike, so renames cannot drift silently.
export const Protocol = Object.freeze({
PING: "ping",
PONG: "pong",
ERROR: "error",
LIST: "list_pipelines",
PIPELINE_LIST: "pipelines",
GET_PIPELINE: "get_pipeline",
PIPELINE: "pipeline",
LIST_TEMPLATES: "list_templates",
TEMPLATES: "templates",
VALIDATE: "validate",
VALIDATED: "validated",
LIST_RUNS: "list_runs",
RUNS: "runs",
GET_RUN: "get_run",
RUN: "run",
// Omni-search (internal/protocol/search.go): the command and its reply type.
// The per-kind payloads and the kind/limit vocabulary live in src/search.js.
SEARCH: "search",
SEARCH_RESULTS: "search_results",
// The run-level operator actions (R11–R14). Each replies with a `run` (or
// `run_started` for retry) envelope carrying the updated run detail; mirrors
// internal/protocol/runs.go and Message.kt.
CANCEL_RUN: "cancel_run",
RETRY_RUN: "retry_run",
DECIDE_RUN: "decide_run",
SET_RUN_TITLE: "set_run_title",
SUCCESS_END: "#success",
FAILURE_END: "#failure",
});
/**
* The integer wire protocol this page speaks. Mirrors `ProtocolVersion` in
* internal/protocol/identity.go and the value the Android client compares in
* `data/protocol/Message.kt` (the `protocol` field of the `pong` reply). It is
* compared as a number, never a string; a differing server value is surfaced as
* a warning rather than silently misread.
*/
export const PROTOCOL_VERSION = 1;
export function isTerminal(target) {
return target === Protocol.SUCCESS_END || target === Protocol.FAILURE_END;
}
/** Mirrors protocol.ResolveTarget: preserve the # shorthand as an explicit terminal. */
export function resolveTarget(outcome, target) {
if (target !== "#") return target;
return outcome === "error" ? Protocol.FAILURE_END : Protocol.SUCCESS_END;
}