@miadi/tide 0.6.10 → 0.6.11
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/package.json +1 -1
- package/src/client.ts +14 -1
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -530,6 +530,8 @@ export interface AgentOpenOptions {
|
|
|
530
530
|
session: string
|
|
531
531
|
/** Resume it when it does not run, instead of returning the plan. */
|
|
532
532
|
run?: boolean
|
|
533
|
+
/** With `run`: the `fingerprint` of the plan the person approved. Another plan does not start. */
|
|
534
|
+
expect?: string
|
|
533
535
|
timeoutMs?: number
|
|
534
536
|
}
|
|
535
537
|
|
|
@@ -553,6 +555,12 @@ export interface TideAgentOpenPlan {
|
|
|
553
555
|
target: "" | "new-session" | "new-window"
|
|
554
556
|
tmux_commands: string[]
|
|
555
557
|
last_seen: string
|
|
558
|
+
/** A headless call, opened as a conversation without its prompt. */
|
|
559
|
+
headless: boolean
|
|
560
|
+
/** What the person approves; send it back as `expect` with `run`. Empty unless `resume`. */
|
|
561
|
+
fingerprint: string
|
|
562
|
+
/** A run whose plan was not the one approved (`expect`): nothing started, and this is the new plan. */
|
|
563
|
+
changed: boolean
|
|
556
564
|
executed: boolean
|
|
557
565
|
}
|
|
558
566
|
|
|
@@ -565,19 +573,24 @@ export interface TideAgentOpenResult {
|
|
|
565
573
|
}
|
|
566
574
|
|
|
567
575
|
export const AGENT_SESSION_KEY = /^[0-9a-f]{8}[0-9a-f-]{0,28}$/
|
|
576
|
+
export const AGENT_PLAN_FINGERPRINT = /^[0-9a-f]{16}$/
|
|
568
577
|
|
|
569
578
|
/**
|
|
570
579
|
* Open one agent session by its id: the pane it runs in, or resumed in a tmux session of the
|
|
571
580
|
* name it last ran under (ironsilk ≥ 0.9.70, `tide agents open`). Dry run unless `run`.
|
|
572
|
-
* Exit 4 (refused) still prints the plan and comes back as an answer.
|
|
581
|
+
* Exit 4 (refused, or a plan other than `expect`) still prints the plan and comes back as an answer.
|
|
573
582
|
*/
|
|
574
583
|
export async function openAgentSession(opts: AgentOpenOptions): Promise<TideAgentOpenResult> {
|
|
575
584
|
const session = opts.session.trim().toLowerCase()
|
|
576
585
|
if (!AGENT_SESSION_KEY.test(session)) {
|
|
577
586
|
throw new TideError(`session must be a session id or its first 8 characters or more: ${JSON.stringify(opts.session)}`)
|
|
578
587
|
}
|
|
588
|
+
if (opts.expect !== undefined && !AGENT_PLAN_FINGERPRINT.test(opts.expect)) {
|
|
589
|
+
throw new TideError(`expect must be a plan fingerprint (16 hex characters): ${JSON.stringify(opts.expect)}`)
|
|
590
|
+
}
|
|
579
591
|
const args = ["agents", "open", session, "--format", "json"]
|
|
580
592
|
if (opts.run) args.push("--run")
|
|
593
|
+
if (opts.run && opts.expect) args.push("--expect", opts.expect)
|
|
581
594
|
const bin = await resolveTideBin()
|
|
582
595
|
const timeoutMs = opts.timeoutMs ?? 60_000
|
|
583
596
|
const env = opts.run ? { ...process.env, TIDE_ALLOW_NON_INTERACTIVE_RUN: "1" } : process.env
|