@skrr-ai/cli 0.1.146 → 0.1.148
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/dist/base-command.js +38 -21
- package/dist/commands/agent/message/send.d.ts +11 -0
- package/dist/commands/agent/message/send.js +34 -8
- package/dist/commands/agent-worker.js +2 -1
- package/dist/commands/agents/activity.js +2 -1
- package/dist/commands/agents/badge.js +10 -5
- package/dist/commands/agents/categories/index.js +2 -1
- package/dist/commands/agents/chat.d.ts +1 -0
- package/dist/commands/agents/chat.js +29 -1
- package/dist/commands/agents/create.js +4 -1
- package/dist/commands/agents/overview.js +2 -1
- package/dist/commands/agents/releases/create.js +2 -1
- package/dist/commands/agents/schedule-overview.js +3 -1
- package/dist/commands/agents/schedule.js +2 -1
- package/dist/commands/agents/spawn.js +9 -6
- package/dist/commands/agents/tools/auth.js +2 -1
- package/dist/commands/agents/tools/calls.js +2 -1
- package/dist/commands/agents/triggers/policy.js +11 -1
- package/dist/commands/agents/visibility.js +2 -1
- package/dist/commands/balance/show.js +28 -5
- package/dist/commands/balance/statement.js +2 -1
- package/dist/commands/commands.js +2 -1
- package/dist/commands/commitments/create.js +2 -1
- package/dist/commands/commitments/delivery.js +2 -1
- package/dist/commands/commitments/doctor.js +2 -1
- package/dist/commands/commitments/observations.js +2 -2
- package/dist/commands/commitments/operating-review.js +2 -1
- package/dist/commands/commitments/pack/preflight.js +2 -1
- package/dist/commands/commitments/preflight.js +5 -1
- package/dist/commands/commitments/trigger-status.js +2 -1
- package/dist/commands/commitments/wake-capabilities.d.ts +2 -0
- package/dist/commands/commitments/wake-capabilities.js +16 -0
- package/dist/commands/convos/messages.js +2 -1
- package/dist/commands/daemon/logs.js +18 -9
- package/dist/commands/daemon/usage.js +2 -1
- package/dist/commands/dm/messages.js +2 -1
- package/dist/commands/dm/thread/messages.js +2 -1
- package/dist/commands/dm/threads.js +2 -1
- package/dist/commands/doctor.js +2 -1
- package/dist/commands/goals/key-results/assess.js +2 -1
- package/dist/commands/goals/key-results/history.js +2 -1
- package/dist/commands/harnesses/forget.js +2 -1
- package/dist/commands/harnesses/show.js +12 -6
- package/dist/commands/inbox/index.js +4 -3
- package/dist/commands/initiatives/decide.js +2 -1
- package/dist/commands/instructions/diff.js +2 -1
- package/dist/commands/instructions/show.js +2 -1
- package/dist/commands/login.js +4 -2
- package/dist/commands/machines/dedicated/cp.js +2 -1
- package/dist/commands/machines/dedicated/power/set.js +2 -1
- package/dist/commands/machines/show.js +2 -1
- package/dist/commands/memory/maintain.js +2 -1
- package/dist/commands/memory/read.js +2 -1
- package/dist/commands/memory/rebuild-index.js +2 -1
- package/dist/commands/memory/rebuild.js +2 -1
- package/dist/commands/memory/search.js +2 -1
- package/dist/commands/messages/list.js +2 -1
- package/dist/commands/revoke-daemon.js +2 -1
- package/dist/commands/revoke-token.js +2 -1
- package/dist/commands/search/all.js +14 -7
- package/dist/commands/search/workspace.js +2 -1
- package/dist/commands/set-capabilities.js +2 -1
- package/dist/commands/skills/browse.js +8 -2
- package/dist/commands/spaces/auto-executor/preview.js +3 -2
- package/dist/commands/spaces/auto-executor/runs.js +4 -1
- package/dist/commands/spaces/workflow-templates/extract.d.ts +1 -0
- package/dist/commands/spaces/workflow-templates/extract.js +9 -1
- package/dist/commands/spaces/workflows/events.js +6 -3
- package/dist/commands/spaces/workflows/run.js +5 -3
- package/dist/commands/spaces/workflows/update.js +2 -1
- package/dist/commands/store/gallery-admissions/preview.js +2 -1
- package/dist/commands/store/publishers/profile/handle.js +2 -1
- package/dist/commands/tasks/comments/anchor.js +23 -9
- package/dist/commands/tasks/complete.js +4 -2
- package/dist/commands/tasks/create-tree.js +7 -3
- package/dist/commands/tasks/create.js +2 -1
- package/dist/commands/tasks/deliverable/add.js +2 -1
- package/dist/commands/tasks/deliverable/archive.js +2 -1
- package/dist/commands/tasks/deliverable/list.js +2 -1
- package/dist/commands/tasks/expectations/assess.js +2 -1
- package/dist/commands/tasks/labels/create.js +2 -1
- package/dist/commands/tasks/preflight.js +4 -2
- package/dist/commands/tasks/ready.js +2 -1
- package/dist/commands/tasks/result/submit.js +2 -1
- package/dist/commands/tasks/updates/add.js +2 -1
- package/dist/commands/tasks/wait.js +2 -1
- package/dist/commands/token/list.js +2 -1
- package/dist/commands/token/mint.js +2 -1
- package/dist/commands/wiki/write.js +14 -7
- package/dist/hooks/command-not-found.js +2 -1
- package/dist/lib/agent-chat-start.d.ts +77 -0
- package/dist/lib/agent-chat-start.js +169 -0
- package/dist/lib/agent-config.js +2 -1
- package/dist/lib/agent-endpoints.js +4 -2
- package/dist/lib/agent-evals.js +2 -1
- package/dist/lib/agent-guide-reference-gate.js +22 -11
- package/dist/lib/agent-guides.js +4 -1
- package/dist/lib/agent-instructions.js +5 -1
- package/dist/lib/agent-ref.js +8 -4
- package/dist/lib/agent-trigger-listing.js +2 -1
- package/dist/lib/agentic-stream.js +8 -5
- package/dist/lib/api-error-reason.js +2 -1
- package/dist/lib/api-fetch.js +5 -3
- package/dist/lib/appData.js +6 -6
- package/dist/lib/appInstallations.js +10 -5
- package/dist/lib/appsCheck.js +2 -1
- package/dist/lib/auth-failure.js +2 -1
- package/dist/lib/auth-storage.js +2 -1
- package/dist/lib/balance.d.ts +33 -3
- package/dist/lib/balance.js +39 -7
- package/dist/lib/capability-matrix.js +4 -2
- package/dist/lib/cli-runtime.js +2 -1
- package/dist/lib/code-handover.js +8 -3
- package/dist/lib/command-hygiene.js +28 -12
- package/dist/lib/command-manifest.js +6 -3
- package/dist/lib/commitment-attention-copy.js +2 -1
- package/dist/lib/commitment-event-wakes.js +9 -0
- package/dist/lib/commitment-product.js +5 -3
- package/dist/lib/commitment-terms.js +2 -1
- package/dist/lib/commitments.d.ts +13 -0
- package/dist/lib/commitments.js +24 -9
- package/dist/lib/compasses.js +2 -1
- package/dist/lib/completion-index.js +2 -1
- package/dist/lib/computer-files.js +8 -6
- package/dist/lib/config.js +11 -5
- package/dist/lib/conversation-search.js +4 -2
- package/dist/lib/daemon-installer.js +6 -2
- package/dist/lib/daemon-maintenance.js +2 -1
- package/dist/lib/daemon-ref.js +2 -1
- package/dist/lib/daemonBroker.js +6 -3
- package/dist/lib/daemonBrokerRefusal.js +4 -2
- package/dist/lib/daemonHandoff.js +14 -7
- package/dist/lib/daemonIslandProfile.js +2 -1
- package/dist/lib/dedicated-copy.js +9 -3
- package/dist/lib/dedicated-exec.js +2 -1
- package/dist/lib/dedicated-keep-awake.js +2 -1
- package/dist/lib/dedicated-machines.js +9 -5
- package/dist/lib/dedicated-service.js +2 -1
- package/dist/lib/dedicated-ssh.js +5 -3
- package/dist/lib/deployed-build.js +2 -1
- package/dist/lib/device-code.js +4 -3
- package/dist/lib/dpop-auth.js +2 -1
- package/dist/lib/earnings.js +2 -1
- package/dist/lib/exec-runtime-binary.js +5 -3
- package/dist/lib/first-party-harness-broker.js +4 -3
- package/dist/lib/first-party-harness-managed.js +2 -1
- package/dist/lib/first-party-harness-startup-update.js +8 -4
- package/dist/lib/first-party-harness-update.js +2 -1
- package/dist/lib/first-party-harness.js +2 -1
- package/dist/lib/format.js +8 -4
- package/dist/lib/git-task.js +10 -5
- package/dist/lib/github-tools.js +6 -3
- package/dist/lib/harnesses.js +4 -2
- package/dist/lib/hosted-machines.js +2 -1
- package/dist/lib/html-text.js +33 -16
- package/dist/lib/ingress.js +2 -1
- package/dist/lib/instruction-blocks.js +2 -1
- package/dist/lib/iso-instant.js +5 -3
- package/dist/lib/keychain.js +15 -5
- package/dist/lib/label-scope.js +2 -1
- package/dist/lib/live-runtime-binary.js +10 -7
- package/dist/lib/local-skills.js +10 -6
- package/dist/lib/login.js +3 -2
- package/dist/lib/machine-audit.js +2 -1
- package/dist/lib/machine-daemon-log.js +2 -1
- package/dist/lib/machine-services.js +2 -1
- package/dist/lib/memory-history-session.js +2 -1
- package/dist/lib/memory-sync.js +6 -2
- package/dist/lib/message-intent.d.ts +10 -0
- package/dist/lib/node-adapter.js +4 -2
- package/dist/lib/northstars.js +4 -2
- package/dist/lib/oauthLogin.js +16 -7
- package/dist/lib/open-target.js +8 -4
- package/dist/lib/option-hint.js +2 -4
- package/dist/lib/outbox.js +2 -1
- package/dist/lib/planOutcome.d.ts +5 -3
- package/dist/lib/planOutcome.js +7 -4
- package/dist/lib/platform-update-local.js +2 -3
- package/dist/lib/preflight-copy.js +31 -0
- package/dist/lib/rate-limit-retry.js +2 -1
- package/dist/lib/reflection.js +2 -1
- package/dist/lib/request-field-flags.js +2 -1
- package/dist/lib/runtime-start-verification.js +2 -1
- package/dist/lib/schedule.js +2 -1
- package/dist/lib/scoped-memory-command.js +7 -3
- package/dist/lib/search-display.js +11 -4
- package/dist/lib/skill-store-pagination.js +2 -1
- package/dist/lib/space-notebook.js +5 -3
- package/dist/lib/store-listing.js +2 -1
- package/dist/lib/task-agent-context-capabilities.js +2 -1
- package/dist/lib/task-asset-upload.js +7 -3
- package/dist/lib/task-closure.js +2 -1
- package/dist/lib/task-economics.js +2 -1
- package/dist/lib/task-execution.js +16 -8
- package/dist/lib/task-extras.js +4 -2
- package/dist/lib/task-operation-watch.js +2 -1
- package/dist/lib/task-preflight.js +3 -2
- package/dist/lib/task-recurrence-summary.js +4 -2
- package/dist/lib/task-runtime-headers.js +10 -5
- package/dist/lib/task-transcript.js +3 -2
- package/dist/lib/task-transfer.js +9 -5
- package/dist/lib/tasks.js +2 -1
- package/dist/lib/triggers.d.ts +21 -0
- package/dist/lib/triggers.js +41 -3
- package/dist/lib/update-check.js +12 -7
- package/dist/lib/usage-discovery.js +2 -1
- package/dist/lib/usd-micros.js +2 -1
- package/dist/lib/web-url.js +2 -1
- package/dist/lib/widgetCheck.js +15 -9
- package/dist/lib/widgetStaticScan.js +26 -14
- package/dist/lib/workflow-run-view.js +5 -3
- package/dist/lib/workflow-templates.d.ts +10 -0
- package/dist/lib/workflow-templates.js +47 -0
- package/dist/lib/write-target.js +4 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/authHelper.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/commitmentExecutionContract.js +22 -12
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerUse.js +4 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelope.js +7 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonConsentProof.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonPair.js +16 -7
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +4 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopDaemonProof.js +4 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/desktopWire.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +11 -7
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceKey.js +7 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dpop.js +8 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.js +4 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessUpdater.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/githubPushRefusal.js +4 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/guidedUpdate.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/independentMachineReservation.js +8 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/kek/macos.js +4 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/liveState.js +4 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loginWithLocalhost.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/loopbackHttp.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/machineUuid.js +4 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileStateDir.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/recoveryCode.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +3 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releasePolicy.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseVersions.js +6 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/restartArtifact.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/telemetryRedaction.js +7 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/authHelper.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.js +27 -18
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerUse.js +6 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelope.js +11 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +6 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonConsentProof.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonPair.js +20 -8
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +5 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopDaemonProof.js +4 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/desktopWire.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +11 -7
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceKey.js +11 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dpop.js +12 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.js +4 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessUpdater.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/githubPushRefusal.js +4 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/guidedUpdate.js +5 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/independentMachineReservation.js +10 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/kek/macos.js +4 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/liveState.js +4 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loginWithLocalhost.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/loopbackHttp.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/machineUuid.js +4 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileStateDir.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/recoveryCode.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +3 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releasePolicy.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseVersions.js +6 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/restartArtifact.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/telemetryRedaction.js +11 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +2 -1
- package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +20519 -20130
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/loopback-server.js +4 -2
- package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +10 -6
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/loopback-server.js +4 -2
- package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +10 -6
- package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
- package/oclif.manifest.json +17 -2
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agent-chat-start.ts — start an agent turn so that "no answer" never means "abandoned".
|
|
4
|
+
*
|
|
5
|
+
* `POST /api/agentic/chat` is an acceptance, not the turn: the server admits the
|
|
6
|
+
* request, reserves the balance for it, queues the run, and only then answers. When
|
|
7
|
+
* that answer is lost — the edge gives up with a 504, the API answers 503 while it is
|
|
8
|
+
* restarting, the socket drops — the CLI cannot tell "never admitted" from "admitted
|
|
9
|
+
* and running". Reporting it as a plain failure (`retryable: false`) is the wrong
|
|
10
|
+
* half of that ambiguity: the turn is usually live, its balance hold is open, and its
|
|
11
|
+
* permission prompts can no longer be answered because the process that would answer
|
|
12
|
+
* them has exited (OSK-22631).
|
|
13
|
+
*
|
|
14
|
+
* The server already has the right contract. A request that carries a
|
|
15
|
+
* `clientRequestId` is admitted exactly once per (user, id): a replay of an accepted
|
|
16
|
+
* request returns the original acceptance (`idempotentReplay: true`, same session and
|
|
17
|
+
* conversation), a replay of one still being admitted answers
|
|
18
|
+
* `409 agentic_request_in_progress` ("retry shortly with the same clientRequestId"),
|
|
19
|
+
* and a different message under the same id is refused. So the client's job is small:
|
|
20
|
+
* name the start, and when the outcome is unknown, send the SAME request again.
|
|
21
|
+
*
|
|
22
|
+
* What is NOT replayed: a refusal that says it cannot help (`retryable: false`, an
|
|
23
|
+
* unconfirmed previous admission, a changed release), any 4xx, and anything that is not
|
|
24
|
+
* an HTTP failure of the transport. Those describe a state the caller has to change
|
|
25
|
+
* first, and replaying them only repeats the refusal.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.StartNotConfirmed = exports.DEFAULT_REPLAY_DELAYS_MS = exports.START_KEY_RULE = void 0;
|
|
29
|
+
exports.newStartKey = newStartKey;
|
|
30
|
+
exports.isValidStartKey = isValidStartKey;
|
|
31
|
+
exports.classifyStartFailure = classifyStartFailure;
|
|
32
|
+
exports.startWithReplay = startWithReplay;
|
|
33
|
+
exports.startNotConfirmedHint = startNotConfirmedHint;
|
|
34
|
+
const node_crypto_1 = require("node:crypto");
|
|
35
|
+
const http_error_1 = require("./http-error");
|
|
36
|
+
/** The server accepts 1-128 characters: letters, numbers, dot, underscore, colon, hyphen. */
|
|
37
|
+
const START_KEY_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
38
|
+
exports.START_KEY_RULE = '1-128 characters: letters, numbers, dot, underscore, colon, hyphen';
|
|
39
|
+
/**
|
|
40
|
+
* Waits between replays. The first replay is quick because most unknown outcomes are a
|
|
41
|
+
* lost answer to a start that already succeeded; the later ones give a restarting API
|
|
42
|
+
* time to come back. Roughly 44 seconds of waiting in total, on top of each attempt.
|
|
43
|
+
*/
|
|
44
|
+
exports.DEFAULT_REPLAY_DELAYS_MS = [2_000, 4_000, 8_000, 15_000, 15_000];
|
|
45
|
+
/** A fresh key for one invocation. Reused by every replay of that invocation, never across them. */
|
|
46
|
+
function newStartKey() {
|
|
47
|
+
return `cli-chat:${(0, node_crypto_1.randomUUID)()}`;
|
|
48
|
+
}
|
|
49
|
+
/** Whether a caller-supplied key is one the server will accept. */
|
|
50
|
+
function isValidStartKey(value) {
|
|
51
|
+
return START_KEY_PATTERN.test(value);
|
|
52
|
+
}
|
|
53
|
+
/** The JSON body of a failed response, when the transport kept it as text or as an object. */
|
|
54
|
+
function bodyOf(err) {
|
|
55
|
+
if (typeof err !== 'object' || err === null)
|
|
56
|
+
return undefined;
|
|
57
|
+
const raw = err.body;
|
|
58
|
+
if (raw && typeof raw === 'object')
|
|
59
|
+
return raw;
|
|
60
|
+
if (typeof raw !== 'string' || !raw.trim().startsWith('{'))
|
|
61
|
+
return undefined;
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(raw);
|
|
64
|
+
return parsed && typeof parsed === 'object' ? parsed : undefined;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const NETWORK_CODES = new Set([
|
|
71
|
+
'ECONNRESET',
|
|
72
|
+
'ECONNABORTED',
|
|
73
|
+
'ETIMEDOUT',
|
|
74
|
+
'EPIPE',
|
|
75
|
+
'EAI_AGAIN',
|
|
76
|
+
'UND_ERR_SOCKET',
|
|
77
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
78
|
+
'UND_ERR_HEADERS_TIMEOUT',
|
|
79
|
+
]);
|
|
80
|
+
/** A request that never produced an HTTP response, from a transport that reports why. */
|
|
81
|
+
function isNetworkFailure(err) {
|
|
82
|
+
if (typeof err !== 'object' || err === null)
|
|
83
|
+
return false;
|
|
84
|
+
const record = err;
|
|
85
|
+
const code = typeof record.code === 'string' ? record.code : undefined;
|
|
86
|
+
if (code && NETWORK_CODES.has(code))
|
|
87
|
+
return true;
|
|
88
|
+
const causeCode = typeof record.cause === 'object' && record.cause !== null
|
|
89
|
+
? record.cause.code
|
|
90
|
+
: undefined;
|
|
91
|
+
if (typeof causeCode === 'string' && NETWORK_CODES.has(causeCode))
|
|
92
|
+
return true;
|
|
93
|
+
return typeof record.message === 'string' && /fetch failed|socket hang up/i.test(record.message);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether a failed start may be sent again under the same key.
|
|
97
|
+
*
|
|
98
|
+
* `replay` is exactly the set of failures where the outcome is unknown or the server
|
|
99
|
+
* said "still being admitted"; `surface` is everything the caller has to act on.
|
|
100
|
+
*/
|
|
101
|
+
function classifyStartFailure(err) {
|
|
102
|
+
const status = (0, http_error_1.httpStatusOf)(err);
|
|
103
|
+
if (status === undefined)
|
|
104
|
+
return isNetworkFailure(err) ? 'replay' : 'surface';
|
|
105
|
+
// The gateway or load balancer answered for the API: the server may have carried on.
|
|
106
|
+
if (status === 502 || status === 504)
|
|
107
|
+
return 'replay';
|
|
108
|
+
const body = bodyOf(err);
|
|
109
|
+
// The API answered itself. 503 says "try again" unless it declares that it cannot help
|
|
110
|
+
// (an unconfirmed earlier admission, `retryable: false`).
|
|
111
|
+
if (status === 503)
|
|
112
|
+
return body?.retryable === false ? 'surface' : 'replay';
|
|
113
|
+
// The same key is already being admitted: waiting and asking again is the documented move.
|
|
114
|
+
if (status === 409 && body?.errorType === 'agentic_request_in_progress')
|
|
115
|
+
return 'replay';
|
|
116
|
+
return 'surface';
|
|
117
|
+
}
|
|
118
|
+
/** Raised when every replay of a start ended without the server confirming the outcome. */
|
|
119
|
+
class StartNotConfirmed extends Error {
|
|
120
|
+
attempts;
|
|
121
|
+
lastError;
|
|
122
|
+
constructor(lastError, attempts) {
|
|
123
|
+
super(`The start was not confirmed after ${attempts} attempt${attempts === 1 ? '' : 's'}.`);
|
|
124
|
+
this.name = 'StartNotConfirmed';
|
|
125
|
+
this.attempts = attempts;
|
|
126
|
+
this.lastError = lastError;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.StartNotConfirmed = StartNotConfirmed;
|
|
130
|
+
const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
131
|
+
/**
|
|
132
|
+
* Run `start`; when it fails with an unknown outcome, run it again — the SAME call, so the
|
|
133
|
+
* same key — after a short wait, up to `delaysMs.length` more times.
|
|
134
|
+
*
|
|
135
|
+
* A failure that is not replayable is thrown untouched on whichever attempt it happens, so
|
|
136
|
+
* existing error handling (and its message) is unchanged. Only running out of replays turns
|
|
137
|
+
* into `StartNotConfirmed`, which carries the last transport error for the caller to render.
|
|
138
|
+
*/
|
|
139
|
+
async function startWithReplay(start, options = {}) {
|
|
140
|
+
const delays = options.delaysMs ?? exports.DEFAULT_REPLAY_DELAYS_MS;
|
|
141
|
+
const sleep = options.sleep ?? defaultSleep;
|
|
142
|
+
let attempts = 0;
|
|
143
|
+
for (;;) {
|
|
144
|
+
attempts += 1;
|
|
145
|
+
try {
|
|
146
|
+
return await start();
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (classifyStartFailure(error) !== 'replay')
|
|
150
|
+
throw error;
|
|
151
|
+
const replayIndex = attempts - 1;
|
|
152
|
+
if (replayIndex >= delays.length)
|
|
153
|
+
throw new StartNotConfirmed(error, attempts);
|
|
154
|
+
const waitMs = delays[replayIndex];
|
|
155
|
+
options.onReplay?.({ attempt: replayIndex + 1, of: delays.length, waitMs, error });
|
|
156
|
+
await sleep(waitMs);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* What to tell a person when the server never confirmed the start. The turn may be running,
|
|
162
|
+
* so the advice is to re-attach with the same key rather than start a second turn.
|
|
163
|
+
*/
|
|
164
|
+
function startNotConfirmedHint(key, attempts) {
|
|
165
|
+
return (`The server never confirmed this start after ${attempts} attempt${attempts === 1 ? '' : 's'}. ` +
|
|
166
|
+
`The turn may still have been accepted and be running. Re-run the same command with ` +
|
|
167
|
+
`--idempotency-key ${key} to attach to it if it was, or to start it once if it was not; ` +
|
|
168
|
+
`a new key could start a second turn.`);
|
|
169
|
+
}
|
package/dist/lib/agent-config.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.parseWorkingHoursFlag = parseWorkingHoursFlag;
|
|
|
7
7
|
exports.mergeAgentConfigFlags = mergeAgentConfigFlags;
|
|
8
8
|
const prompt_1 = require("./prompt");
|
|
9
9
|
const agent_visual_refs_1 = require("./agent-visual-refs");
|
|
10
|
+
const PARSE_WORKING_HOURS_FLAG_RE = /^([0-2]\d:[0-5]\d)-([0-2]\d:[0-5]\d)$/;
|
|
10
11
|
/**
|
|
11
12
|
* The fields the server ignored and why, from a write's `deprecatedFields`
|
|
12
13
|
* notice, one line each. Empty when the response carries none.
|
|
@@ -41,7 +42,7 @@ function parseWorkingHoursFlag(value) {
|
|
|
41
42
|
if (trimmed.startsWith('{'))
|
|
42
43
|
return JSON.parse(trimmed);
|
|
43
44
|
const [window, timezone] = trimmed.split('@');
|
|
44
|
-
const match =
|
|
45
|
+
const match = PARSE_WORKING_HOURS_FLAG_RE.exec(window ?? '');
|
|
45
46
|
if (!match) {
|
|
46
47
|
throw new Error(`--todo-working-hours: cannot read "${value}". ` +
|
|
47
48
|
'Write HH:MM-HH:MM, optionally @<IANA timezone> — for example ' +
|
|
@@ -8,6 +8,8 @@ exports.describeEndpointState = describeEndpointState;
|
|
|
8
8
|
exports.endpointWillRun = endpointWillRun;
|
|
9
9
|
exports.printAgentEndpoint = printAgentEndpoint;
|
|
10
10
|
const api_fetch_1 = require("./api-fetch");
|
|
11
|
+
const MCP_CLIENT_COMMAND_RE = /[^A-Za-z0-9_-]/g;
|
|
12
|
+
const PRINT_AGENT_ENDPOINT_RE = /_/g;
|
|
11
13
|
async function getAgentEndpoint(agentId) {
|
|
12
14
|
return (0, api_fetch_1.apiFetch)(`/api/agent-endpoints/${encodeURIComponent(agentId)}`);
|
|
13
15
|
}
|
|
@@ -25,7 +27,7 @@ exports.AGENT_ENDPOINT_SCOPE = 'agents:invoke';
|
|
|
25
27
|
* header; any other client needs the same two facts (URL, bearer key).
|
|
26
28
|
*/
|
|
27
29
|
function mcpClientCommand(endpoint, secret) {
|
|
28
|
-
const name = `skrr-${endpoint.agent_id}`.replace(
|
|
30
|
+
const name = `skrr-${endpoint.agent_id}`.replace(MCP_CLIENT_COMMAND_RE, '-');
|
|
29
31
|
return `claude mcp add --transport http ${name} ${endpoint.url} --header "Authorization: Bearer ${secret}"`;
|
|
30
32
|
}
|
|
31
33
|
/** One human line for the state an endpoint is in. */
|
|
@@ -51,7 +53,7 @@ function endpointWillRun(endpoint) {
|
|
|
51
53
|
/** The human rendering every `agents endpoint` command prints. */
|
|
52
54
|
function printAgentEndpoint(cmd, endpoint) {
|
|
53
55
|
cmd.log(`Agent ${endpoint.agent_id}${endpoint.agent_name ? ` (${endpoint.agent_name})` : ''}`);
|
|
54
|
-
cmd.log(`Kind ${endpoint.kind.replace(
|
|
56
|
+
cmd.log(`Kind ${endpoint.kind.replace(PRINT_AGENT_ENDPOINT_RE, ' ')}`);
|
|
55
57
|
cmd.log(`Endpoint ${describeEndpointState(endpoint)}`);
|
|
56
58
|
if (endpoint.blocked_by?.remedy) {
|
|
57
59
|
cmd.log(`Next step ${endpoint.blocked_by.remedy}`);
|
package/dist/lib/agent-evals.js
CHANGED
|
@@ -55,6 +55,7 @@ const fs = __importStar(require("node:fs"));
|
|
|
55
55
|
const path = __importStar(require("node:path"));
|
|
56
56
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
57
57
|
const http_error_1 = require("./http-error");
|
|
58
|
+
const PICK_RELEASE_RE = /^v/i;
|
|
58
59
|
/** CLI spelling → API spelling. */
|
|
59
60
|
exports.EVAL_BASELINE_FLAG_VALUES = {
|
|
60
61
|
'no-agent': 'no_agent',
|
|
@@ -134,7 +135,7 @@ function pickRelease(releases, wanted) {
|
|
|
134
135
|
if (!wanted) {
|
|
135
136
|
return [...releases].sort((a, b) => (b.releaseNumber ?? 0) - (a.releaseNumber ?? 0))[0];
|
|
136
137
|
}
|
|
137
|
-
const label = wanted.replace(
|
|
138
|
+
const label = wanted.replace(PICK_RELEASE_RE, '');
|
|
138
139
|
return releases.find((release) => release.id === wanted || release.versionLabel === label);
|
|
139
140
|
}
|
|
140
141
|
/** The planned trials that have no graded result yet, in run order. */
|
|
@@ -5,6 +5,15 @@ exports.assertMcpGuideToolReferences = assertMcpGuideToolReferences;
|
|
|
5
5
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
6
6
|
const command_miss_1 = require("./command-miss");
|
|
7
7
|
const command_manifest_1 = require("./command-manifest");
|
|
8
|
+
const COMMAND_WORDS_RE = /\s+/;
|
|
9
|
+
const COMMAND_WORDS_RE_2 = /^[a-z][a-z0-9-]*$/i;
|
|
10
|
+
const COMMAND_CATALOG_RE = /:/g;
|
|
11
|
+
const COMMAND_CATALOG_RE_2 = /^--/;
|
|
12
|
+
const ASSERT_CLI_GUIDE_REFERENCES_RE = /\bskrr(?:\s+[^\s`]+)*/g;
|
|
13
|
+
const IS_TOOL_REFERENCE_RE = /\b(?:call|use|invoke|run)\s*$/i;
|
|
14
|
+
const IS_TOOL_REFERENCE_RE_2 = /\b(?:MCP\s+)?tools?\s*$/i;
|
|
15
|
+
const IS_TOOL_REFERENCE_RE_3 = /^\s*(?:MCP\s+)?tool\b/i;
|
|
16
|
+
const IS_TOOL_REFERENCE_RE_4 = /^\s*(?:[-*]|\d+\.)\s*$/;
|
|
8
17
|
const FENCE = /^ {0,3}(`{3,}|~{3,})(.*)$/;
|
|
9
18
|
const INLINE_CODE = /`([^`\n]+)`/g;
|
|
10
19
|
const FLAG = /(?<!-)--([a-z][a-z0-9-]*)\b/g;
|
|
@@ -16,10 +25,10 @@ function location(document, line, problem) {
|
|
|
16
25
|
}
|
|
17
26
|
function commandWords(text) {
|
|
18
27
|
const words = [];
|
|
19
|
-
for (const token of text.trim().split(
|
|
28
|
+
for (const token of text.trim().split(COMMAND_WORDS_RE)) {
|
|
20
29
|
if (token.startsWith('--') || token.startsWith('<') || token.startsWith('['))
|
|
21
30
|
break;
|
|
22
|
-
if (
|
|
31
|
+
if (!COMMAND_WORDS_RE_2.test(token))
|
|
23
32
|
break;
|
|
24
33
|
words.push(token.toLowerCase());
|
|
25
34
|
}
|
|
@@ -59,7 +68,7 @@ function commandCatalog(manifest) {
|
|
|
59
68
|
for (const entry of (0, command_manifest_1.visibleCommandEntries)(manifest)) {
|
|
60
69
|
ids.push(entry.id);
|
|
61
70
|
for (const name of [entry.command, ...entry.aliases]) {
|
|
62
|
-
const words = commandWords(name.replace(
|
|
71
|
+
const words = commandWords(name.replace(COMMAND_CATALOG_RE, ' '));
|
|
63
72
|
if (words.length)
|
|
64
73
|
spellings.push({ words, id: entry.id });
|
|
65
74
|
}
|
|
@@ -72,7 +81,7 @@ function commandCatalog(manifest) {
|
|
|
72
81
|
if (Array.isArray(aliases)) {
|
|
73
82
|
for (const alias of aliases) {
|
|
74
83
|
if (typeof alias === 'string')
|
|
75
|
-
flags.add(alias.replace(
|
|
84
|
+
flags.add(alias.replace(COMMAND_CATALOG_RE_2, ''));
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
87
|
}
|
|
@@ -83,12 +92,12 @@ function commandCatalog(manifest) {
|
|
|
83
92
|
function assertCliGuideReferences(documents, manifest, globalFlags = []) {
|
|
84
93
|
const catalog = commandCatalog(manifest);
|
|
85
94
|
for (const flag of globalFlags)
|
|
86
|
-
catalog.flags.add(flag.replace(
|
|
95
|
+
catalog.flags.add(flag.replace(COMMAND_CATALOG_RE_2, ''));
|
|
87
96
|
for (const document of documents) {
|
|
88
97
|
if (document.surface !== 'cli')
|
|
89
98
|
continue;
|
|
90
99
|
for (const span of codeSpans(document)) {
|
|
91
|
-
for (const match of span.text.matchAll(
|
|
100
|
+
for (const match of span.text.matchAll(ASSERT_CLI_GUIDE_REFERENCES_RE)) {
|
|
92
101
|
const typed = commandWords(match[0].slice('skrr'.length));
|
|
93
102
|
if (!typed.length)
|
|
94
103
|
continue;
|
|
@@ -103,7 +112,9 @@ function assertCliGuideReferences(documents, manifest, globalFlags = []) {
|
|
|
103
112
|
if (catalog.ids.some((known) => known.startsWith(`${id}:`)))
|
|
104
113
|
continue;
|
|
105
114
|
const nearest = (0, command_miss_1.nearestCommands)(id, catalog.ids)[0];
|
|
106
|
-
throw location(document, span.line, `unknown \`skrr ${typed.join(' ')}\` command${nearest
|
|
115
|
+
throw location(document, span.line, `unknown \`skrr ${typed.join(' ')}\` command${nearest
|
|
116
|
+
? `; nearest real command: \`skrr ${nearest.replace(COMMAND_CATALOG_RE, ' ')}\``
|
|
117
|
+
: ''}`);
|
|
107
118
|
}
|
|
108
119
|
}
|
|
109
120
|
for (const source of document.lines) {
|
|
@@ -122,12 +133,12 @@ function isToolReference(line, start, end, name, known) {
|
|
|
122
133
|
return true;
|
|
123
134
|
const before = line.slice(0, start);
|
|
124
135
|
const after = line.slice(end);
|
|
125
|
-
return (
|
|
136
|
+
return (IS_TOOL_REFERENCE_RE.test(before) ||
|
|
126
137
|
// "the `x` tool" / "tool `x`": the word must sit beside the name, since a
|
|
127
138
|
// line that mentions tools elsewhere often names an argument too.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
IS_TOOL_REFERENCE_RE_2.test(before) ||
|
|
140
|
+
IS_TOOL_REFERENCE_RE_3.test(after) ||
|
|
141
|
+
IS_TOOL_REFERENCE_RE_4.test(before));
|
|
131
142
|
}
|
|
132
143
|
function nearestTool(name, names) {
|
|
133
144
|
return (0, data_provider_1.nearestAgentGuideIds)(name, names, 1)[0] ?? '';
|
package/dist/lib/agent-guides.js
CHANGED
|
@@ -19,6 +19,7 @@ const http_error_1 = require("./http-error");
|
|
|
19
19
|
const keychain_1 = require("./keychain");
|
|
20
20
|
const config_1 = require("./config");
|
|
21
21
|
const node_adapter_1 = require("./node-adapter");
|
|
22
|
+
const GUIDE_READ_TELEMETRY_HEADERS_RE = /[\r\n]/;
|
|
22
23
|
const bundle = agent_guides_json_1.default;
|
|
23
24
|
/**
|
|
24
25
|
* An opaque correlation hint for guide-read telemetry. It is not
|
|
@@ -31,7 +32,9 @@ exports.GUIDE_READ_CONTEXT_HEADER = 'X-Oversky-Guide-Read-Context';
|
|
|
31
32
|
const GUIDE_READ_CONTEXT_MAX_CHARS = 256;
|
|
32
33
|
function guideReadTelemetryHeaders(env = process.env) {
|
|
33
34
|
const context = (env.OVERSKY_GUIDE_READ_CONTEXT ?? env.OVERSKY_SESSION_ID ?? '').trim();
|
|
34
|
-
if (!context ||
|
|
35
|
+
if (!context ||
|
|
36
|
+
context.length > GUIDE_READ_CONTEXT_MAX_CHARS ||
|
|
37
|
+
GUIDE_READ_TELEMETRY_HEADERS_RE.test(context)) {
|
|
35
38
|
return undefined;
|
|
36
39
|
}
|
|
37
40
|
return { [exports.GUIDE_READ_CONTEXT_HEADER]: context };
|
|
@@ -7,6 +7,7 @@ exports.renderCompositionLines = renderCompositionLines;
|
|
|
7
7
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
8
8
|
const agent_resolver_1 = require("./agent-resolver");
|
|
9
9
|
const instruction_blocks_1 = require("./instruction-blocks");
|
|
10
|
+
const RENDER_COMPOSITION_LINES_RE = /\s+/g;
|
|
10
11
|
/** Positional and --agent forms agree with the existing `agents tone` UX. */
|
|
11
12
|
async function resolveInstructionAgentId(argument, flag) {
|
|
12
13
|
return (0, agent_resolver_1.resolveAgentId)((0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
@@ -36,7 +37,10 @@ function renderCompositionLines(composition) {
|
|
|
36
37
|
return composition.entries.flatMap((entry, index) => {
|
|
37
38
|
const state = entry.enabled ? 'on' : 'off';
|
|
38
39
|
if (entry.source.kind === 'inline') {
|
|
39
|
-
const preview = entry.source.body
|
|
40
|
+
const preview = entry.source.body
|
|
41
|
+
.trim()
|
|
42
|
+
.replace(RENDER_COMPOSITION_LINES_RE, ' ')
|
|
43
|
+
.slice(0, 140);
|
|
40
44
|
return [
|
|
41
45
|
`${index + 1}. ${state.padEnd(3)} inline ${entry.source.title} (${entry.instanceId})`,
|
|
42
46
|
` ${preview || '(empty)'}`,
|
package/dist/lib/agent-ref.js
CHANGED
|
@@ -9,6 +9,10 @@ exports.shellQuote = shellQuote;
|
|
|
9
9
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
10
10
|
const http_error_1 = require("./http-error");
|
|
11
11
|
const web_url_1 = require("./web-url");
|
|
12
|
+
const RESOLVE_BY_CODE_RE = /_/g;
|
|
13
|
+
const RESOLVE_AGENT_REF_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
14
|
+
const SHELL_QUOTE_RE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
15
|
+
const SHELL_QUOTE_RE_2 = /'/g;
|
|
12
16
|
class AgentRefError extends Error {
|
|
13
17
|
code;
|
|
14
18
|
constructor(message, code) {
|
|
@@ -94,7 +98,7 @@ async function resolveByCode(value, attribution, options) {
|
|
|
94
98
|
'unpublished, or the link was copied incompletely.', 'AGENT_REF_CODE_UNRESOLVED');
|
|
95
99
|
}
|
|
96
100
|
if (resolved.entity.kind !== 'agent') {
|
|
97
|
-
throw new AgentRefError(`"${value}" is a link to a ${resolved.entity.kind.replace(
|
|
101
|
+
throw new AgentRefError(`"${value}" is a link to a ${resolved.entity.kind.replace(RESOLVE_BY_CODE_RE, ' ')}, not an agent.`, 'AGENT_REF_NOT_AN_AGENT');
|
|
98
102
|
}
|
|
99
103
|
return {
|
|
100
104
|
agentId: resolved.entity.id,
|
|
@@ -115,7 +119,7 @@ async function resolveAgentRef(input, options = {}) {
|
|
|
115
119
|
firstPartyHosts: cliFirstPartyHosts(options.baseURL),
|
|
116
120
|
});
|
|
117
121
|
if (!inspected) {
|
|
118
|
-
throw
|
|
122
|
+
throw RESOLVE_AGENT_REF_RE.test(value)
|
|
119
123
|
? new AgentRefError(`"${value}" is not a ${data_provider_1.BRAND.displayName} link, so it was not followed. Pass an agent ` +
|
|
120
124
|
`id or a link on ${data_provider_1.BRAND.displayName}'s own site.`, 'AGENT_REF_FOREIGN')
|
|
121
125
|
: unsupported(value);
|
|
@@ -137,7 +141,7 @@ async function resolveAgentRef(input, options = {}) {
|
|
|
137
141
|
return resolveByCode(value, attribution, options);
|
|
138
142
|
throw unsupported(value);
|
|
139
143
|
default:
|
|
140
|
-
throw new AgentRefError(`"${value}" is a link to a ${link.kind.replace(
|
|
144
|
+
throw new AgentRefError(`"${value}" is a link to a ${link.kind.replace(RESOLVE_BY_CODE_RE, ' ')}, not an agent.`, 'AGENT_REF_NOT_AN_AGENT');
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
function unsupported(value) {
|
|
@@ -164,5 +168,5 @@ function installAttribution(attribution) {
|
|
|
164
168
|
}
|
|
165
169
|
/** Quote a URL for a POSIX shell: `?` and `&` in an attributed link are metacharacters. */
|
|
166
170
|
function shellQuote(value) {
|
|
167
|
-
return
|
|
171
|
+
return SHELL_QUOTE_RE.test(value) ? value : `'${value.replace(SHELL_QUOTE_RE_2, `'\\''`)}'`;
|
|
168
172
|
}
|
|
@@ -17,6 +17,7 @@ exports.triggersMissingFromAgentList = triggersMissingFromAgentList;
|
|
|
17
17
|
exports.isSuspended = isSuspended;
|
|
18
18
|
exports.sourceLabel = sourceLabel;
|
|
19
19
|
exports.systemManagedLegend = systemManagedLegend;
|
|
20
|
+
const IS_SYSTEM_MANAGED_RE = /^commitment-(check|reflect):/;
|
|
20
21
|
function idOf(row) {
|
|
21
22
|
return typeof row.id === 'string' ? row.id : '';
|
|
22
23
|
}
|
|
@@ -26,7 +27,7 @@ function scopeKindOf(row) {
|
|
|
26
27
|
}
|
|
27
28
|
/** Created and run by the platform for a Commitment, not authored by the person. */
|
|
28
29
|
function isSystemManaged(row) {
|
|
29
|
-
return row.producerOwned === true ||
|
|
30
|
+
return row.producerOwned === true || IS_SYSTEM_MANAGED_RE.test(idOf(row));
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* The universal-list rows the per-agent facade did not return, each tagged `systemManaged`.
|
|
@@ -35,6 +35,9 @@ const config_1 = require("./config");
|
|
|
35
35
|
const widgetTerminalText_1 = require("./widgetTerminalText");
|
|
36
36
|
const publicEndpoints_generated_1 = require("./publicEndpoints.generated");
|
|
37
37
|
const dpop_auth_1 = require("./dpop-auth");
|
|
38
|
+
const SQUASH_RE = /\s+/g;
|
|
39
|
+
const HANDLE_PERMISSION_RE = /^y(es)?$/i;
|
|
40
|
+
const TO_WEB_SOCKET_ORIGIN_RE = /\/$/;
|
|
38
41
|
/**
|
|
39
42
|
* Why a question was dismissed when no terminal exists to ask it on. It is the
|
|
40
43
|
* REASON for a dismissal, never an answer: it travels as the value of the
|
|
@@ -759,7 +762,7 @@ function seqGapNotice(gaps, options = {}) {
|
|
|
759
762
|
* stream never showed — and that is the only thing this answers yes to.
|
|
760
763
|
*/
|
|
761
764
|
function streamShowsRecordedText(streamed, recorded) {
|
|
762
|
-
const squash = (s) => s.replace(
|
|
765
|
+
const squash = (s) => s.replace(SQUASH_RE, '');
|
|
763
766
|
return squash(streamed).includes(squash(recorded));
|
|
764
767
|
}
|
|
765
768
|
const defaultStreamDebug = (line) => {
|
|
@@ -799,13 +802,13 @@ function describeRunPermission(event) {
|
|
|
799
802
|
}
|
|
800
803
|
/** `tail` is the end of `whole`, whitespace aside. */
|
|
801
804
|
function endsWithIgnoringWhitespace(whole, tail) {
|
|
802
|
-
const solid = (value) => value.replace(
|
|
805
|
+
const solid = (value) => value.replace(SQUASH_RE, '');
|
|
803
806
|
const wanted = solid(tail);
|
|
804
807
|
return wanted.length > 0 && solid(whole).endsWith(wanted);
|
|
805
808
|
}
|
|
806
809
|
/** `head` is the start of `whole`, whitespace aside. */
|
|
807
810
|
function startsWithIgnoringWhitespace(whole, head) {
|
|
808
|
-
const solid = (value) => value.replace(
|
|
811
|
+
const solid = (value) => value.replace(SQUASH_RE, '');
|
|
809
812
|
const wanted = solid(head);
|
|
810
813
|
return wanted.length > 0 && solid(whole).startsWith(wanted);
|
|
811
814
|
}
|
|
@@ -1928,7 +1931,7 @@ class AgenticStreamClient {
|
|
|
1928
1931
|
// there is nothing left to answer, and a late "no" would read as a person's.
|
|
1929
1932
|
if (prompt.signal.aborted)
|
|
1930
1933
|
return;
|
|
1931
|
-
const approved =
|
|
1934
|
+
const approved = HANDLE_PERMISSION_RE.test(answer.trim());
|
|
1932
1935
|
// Recorded before the decision is sent, so the call's end can never arrive first.
|
|
1933
1936
|
if (!approved && event.toolUseId)
|
|
1934
1937
|
this.deniedToolUseIds.add(event.toolUseId);
|
|
@@ -2856,5 +2859,5 @@ function toWebSocketOrigin(baseURL) {
|
|
|
2856
2859
|
url.pathname = '';
|
|
2857
2860
|
url.search = '';
|
|
2858
2861
|
url.hash = '';
|
|
2859
|
-
return url.toString().replace(
|
|
2862
|
+
return url.toString().replace(TO_WEB_SOCKET_ORIGIN_RE, '');
|
|
2860
2863
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reasonOnlyCode = reasonOnlyCode;
|
|
4
|
+
const REASON_ONLY_CODE_RE = /^[A-Za-z][A-Za-z0-9]*(?:[_-][A-Za-z0-9]+)+$/;
|
|
4
5
|
/** The reason-only refusal used by session-scoped API routes. */
|
|
5
6
|
function reasonOnlyCode(body) {
|
|
6
7
|
if (!body || typeof body !== 'object' || Array.isArray(body))
|
|
@@ -9,6 +10,6 @@ function reasonOnlyCode(body) {
|
|
|
9
10
|
if (value.ok !== false || typeof value.reason !== 'string')
|
|
10
11
|
return undefined;
|
|
11
12
|
const reason = value.reason.trim();
|
|
12
|
-
return reason.length <= 160 &&
|
|
13
|
+
return reason.length <= 160 && REASON_ONLY_CODE_RE.test(reason)
|
|
13
14
|
? reason : undefined;
|
|
14
15
|
}
|
package/dist/lib/api-fetch.js
CHANGED
|
@@ -51,6 +51,8 @@ const task_runtime_headers_1 = require("./task-runtime-headers");
|
|
|
51
51
|
const non_json_response_1 = require("./non-json-response");
|
|
52
52
|
const rate_limit_retry_1 = require("./rate-limit-retry");
|
|
53
53
|
const memory_history_session_1 = require("./memory-history-session");
|
|
54
|
+
const API_FETCH_RE = /^https?:\/\//i;
|
|
55
|
+
const API_FETCH_RE_2 = /\/+$/;
|
|
54
56
|
class ApiFetchError extends Error {
|
|
55
57
|
status;
|
|
56
58
|
body;
|
|
@@ -118,11 +120,11 @@ async function apiFetch(pathOrUrl, opts = {}) {
|
|
|
118
120
|
: sessionCredential;
|
|
119
121
|
const baseURL = autonomousCredential ? trustedAutonomousBaseUrl() : (0, config_1.loadConfig)().baseURL;
|
|
120
122
|
const method = opts.method ?? 'GET';
|
|
121
|
-
const url = historyRead?.url ?? (
|
|
123
|
+
const url = historyRead?.url ?? (API_FETCH_RE.test(pathOrUrl)
|
|
122
124
|
? autonomousCredential
|
|
123
125
|
? assertTrustedAutonomousUrl(pathOrUrl, baseURL)
|
|
124
126
|
: pathOrUrl
|
|
125
|
-
: `${baseURL.replace(
|
|
127
|
+
: `${baseURL.replace(API_FETCH_RE_2, '')}${pathOrUrl.startsWith('/') ? '' : '/'}${pathOrUrl}`);
|
|
126
128
|
// A FormData body passes through untouched — fetch sets the multipart
|
|
127
129
|
// boundary itself, and stringifying would destroy it. Upload commands
|
|
128
130
|
// (tasks attachments) need this on the session-scoped path, which is not
|
|
@@ -408,7 +410,7 @@ function assertTrustedAutonomousUrl(url, baseURL) {
|
|
|
408
410
|
}
|
|
409
411
|
function isAuthEndpoint(pathOrUrl) {
|
|
410
412
|
try {
|
|
411
|
-
const path =
|
|
413
|
+
const path = API_FETCH_RE.test(pathOrUrl) ? new URL(pathOrUrl).pathname : pathOrUrl;
|
|
412
414
|
return path.includes('/api/auth/');
|
|
413
415
|
}
|
|
414
416
|
catch {
|
package/dist/lib/appData.js
CHANGED
|
@@ -34,6 +34,10 @@ exports.formatQueryResult = formatQueryResult;
|
|
|
34
34
|
*/
|
|
35
35
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
36
36
|
const appsFs_1 = require("./appsFs");
|
|
37
|
+
// eslint-disable-next-line no-control-regex, no-misleading-character-class -- the point of the pattern is to match control, combining and invisible characters
|
|
38
|
+
const SAFE_FOR_TERMINAL_RE =
|
|
39
|
+
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
40
|
+
/[\u0000-\u001f\u007f-\u009f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\ufeff\uffa0\ufff9-\ufffb\u{1d173}-\u{1d17a}\u{e0000}-\u{e03ff}]/gu;
|
|
37
41
|
// ── what a document is, and where it comes from ─────────────────────────────
|
|
38
42
|
/** Why the input could not be used; never carries what was in it. */
|
|
39
43
|
class AppDataInputError extends Error {
|
|
@@ -230,13 +234,9 @@ function describePersonDataConflict(failure, target, bin) {
|
|
|
230
234
|
* already escapes everything below U+0020, but not these.
|
|
231
235
|
*/
|
|
232
236
|
function safeForTerminal(text) {
|
|
233
|
-
return text.replace(
|
|
234
|
-
// eslint-disable-next-line no-control-regex, no-misleading-character-class -- the point of the pattern is to match control, combining and invisible characters
|
|
235
|
-
/[\u0000-\u001f\u007f-\u009f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\ufeff\uffa0\ufff9-\ufffb\u{1d173}-\u{1d17a}\u{e0000}-\u{e03ff}]/gu, (c) => {
|
|
237
|
+
return text.replace(SAFE_FOR_TERMINAL_RE, (c) => {
|
|
236
238
|
const code = c.codePointAt(0) ?? 0;
|
|
237
|
-
return code > 0xffff
|
|
238
|
-
? `\\u{${code.toString(16)}}`
|
|
239
|
-
: `\\u${code.toString(16).padStart(4, '0')}`;
|
|
239
|
+
return code > 0xffff ? `\\u{${code.toString(16)}}` : `\\u${code.toString(16).padStart(4, '0')}`;
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
const DATA_LINE_MAX = 400;
|
|
@@ -41,6 +41,11 @@ exports.installationRefusalExit = installationRefusalExit;
|
|
|
41
41
|
* next step.
|
|
42
42
|
*/
|
|
43
43
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
44
|
+
const DESCRIBE_SCHEDULE_RE = /s$/;
|
|
45
|
+
const FORMAT_JOB_STATES_RE = /<installation>/g;
|
|
46
|
+
const ITEM_LINES_RE = /_/g;
|
|
47
|
+
const FORMAT_DISCLOSURE_RE = /^ {4}/;
|
|
48
|
+
const FORMAT_DISCLOSURE_RE_2 = /^ {4}(?=- )/;
|
|
44
49
|
// ── what an installation is, in a line ──────────────────────────────────────
|
|
45
50
|
const AVAILABILITY_WORDS = {
|
|
46
51
|
ready: 'ready',
|
|
@@ -137,7 +142,7 @@ function describeSchedule(schedule) {
|
|
|
137
142
|
case 'daily':
|
|
138
143
|
return `every day at ${reading.times.join(' and ')}`;
|
|
139
144
|
case 'every':
|
|
140
|
-
return `every ${reading.count === 1 ? reading.unit.replace(
|
|
145
|
+
return `every ${reading.count === 1 ? reading.unit.replace(DESCRIBE_SCHEDULE_RE, '') : `${reading.count} ${reading.unit}`}`;
|
|
141
146
|
case 'configured':
|
|
142
147
|
return "on a schedule set in the app's settings";
|
|
143
148
|
default:
|
|
@@ -280,7 +285,7 @@ function formatJobStates(jobStates, installationId) {
|
|
|
280
285
|
}
|
|
281
286
|
lines.push(` job ${(0, data_provider_1.plainAppLabel)(job.id, 64)}: NOT SCHEDULED: ${words.what}`);
|
|
282
287
|
if (words.next) {
|
|
283
|
-
lines.push(` next: ${words.next.replace(
|
|
288
|
+
lines.push(` next: ${words.next.replace(FORMAT_JOB_STATES_RE, installationId)}`);
|
|
284
289
|
}
|
|
285
290
|
}
|
|
286
291
|
return lines;
|
|
@@ -338,7 +343,7 @@ function jobNextLine(job) {
|
|
|
338
343
|
if (stateReason.state === 'unknown' && live) {
|
|
339
344
|
return [];
|
|
340
345
|
}
|
|
341
|
-
return [` next: ${stateReason.next.replace(
|
|
346
|
+
return [` next: ${stateReason.next.replace(FORMAT_JOB_STATES_RE, '<installation id>')}`];
|
|
342
347
|
}
|
|
343
348
|
function itemLines(item) {
|
|
344
349
|
switch (item.kind) {
|
|
@@ -367,7 +372,7 @@ function itemLines(item) {
|
|
|
367
372
|
case 'service': {
|
|
368
373
|
const declaration = item.declaration;
|
|
369
374
|
const lines = [
|
|
370
|
-
`run a background program (${declaration.protocol}, ${declaration.liveness.replace(
|
|
375
|
+
`run a background program (${declaration.protocol}, ${declaration.liveness.replace(ITEM_LINES_RE, ' ')}), ${ISOLATION_WORDS[declaration.isolation] ?? declaration.isolation}; this stops working if the app's code changes, until you approve again${mark(item.consent)}`,
|
|
371
376
|
` command: ${declaration.command.join(' ')}`,
|
|
372
377
|
];
|
|
373
378
|
if (declaration.secretNames.length > 0) {
|
|
@@ -448,7 +453,7 @@ function formatDisclosure(raw, facts) {
|
|
|
448
453
|
const [first, ...rest] = itemLines(item);
|
|
449
454
|
if (first !== undefined) {
|
|
450
455
|
lines.push(` - ${first}`);
|
|
451
|
-
lines.push(...rest.map((line) => ` ${line.replace(
|
|
456
|
+
lines.push(...rest.map((line) => ` ${line.replace(FORMAT_DISCLOSURE_RE, '')}`.replace(FORMAT_DISCLOSURE_RE_2, ' ')));
|
|
452
457
|
}
|
|
453
458
|
}
|
|
454
459
|
}
|
package/dist/lib/appsCheck.js
CHANGED
|
@@ -53,6 +53,7 @@ exports.formatAppCheckReport = formatAppCheckReport;
|
|
|
53
53
|
const vm = __importStar(require("node:vm"));
|
|
54
54
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
55
55
|
const widgetStaticScan_1 = require("./widgetStaticScan");
|
|
56
|
+
const COMPILE_SCRIPT_RE = /^app\.js:(\d+)/;
|
|
56
57
|
/** Compile `source` as a classic script and say what is wrong with it, or null. */
|
|
57
58
|
function compileScript(source) {
|
|
58
59
|
try {
|
|
@@ -63,7 +64,7 @@ function compileScript(source) {
|
|
|
63
64
|
const message = error?.message;
|
|
64
65
|
const stack = error?.stack;
|
|
65
66
|
const head = typeof stack === 'string' ? stack.split('\n')[0] : '';
|
|
66
|
-
const at =
|
|
67
|
+
const at = COMPILE_SCRIPT_RE.exec(head);
|
|
67
68
|
return {
|
|
68
69
|
message: typeof message === 'string' ? message : String(error),
|
|
69
70
|
...(at ? { line: Number(at[1]) } : {}),
|
package/dist/lib/auth-failure.js
CHANGED
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.refusalFromResponse = refusalFromResponse;
|
|
17
17
|
exports.describeRefreshRefusal = describeRefreshRefusal;
|
|
18
18
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
19
|
+
const DESCRIBE_REFRESH_REFUSAL_RE = /bound to a different daemon/i;
|
|
19
20
|
/**
|
|
20
21
|
* OSK-16941 — the refusal an API 401 body describes, when it is a revoked
|
|
21
22
|
* session (`{ code: 'SESSION_REVOKED', reason }`). Lets the 401 explain itself
|
|
@@ -64,7 +65,7 @@ function describeRefreshRefusal(refusal, opts) {
|
|
|
64
65
|
// read refuses a bundle bound to another cliId before presenting it, so this
|
|
65
66
|
// is now reached only when the server's binding disagrees with a token that
|
|
66
67
|
// carries no readable `did`.
|
|
67
|
-
if (
|
|
68
|
+
if (DESCRIBE_REFRESH_REFUSAL_RE.test(message)) {
|
|
68
69
|
return {
|
|
69
70
|
code,
|
|
70
71
|
message: `This profile's stored sign-in could not be renewed${said}. The credential in its ` +
|