@archal/cli 0.7.12 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/bin/archal.cjs +15 -0
- package/dist/harnesses/_lib/agent-trace.mjs +57 -0
- package/dist/harnesses/_lib/env-utils.mjs +23 -0
- package/dist/harnesses/_lib/harness-runner.mjs +354 -0
- package/dist/harnesses/_lib/llm-call.mjs +411 -0
- package/dist/harnesses/_lib/llm-config.mjs +209 -0
- package/dist/harnesses/_lib/llm-response.mjs +483 -0
- package/dist/harnesses/_lib/logging.mjs +176 -0
- package/dist/harnesses/_lib/mcp-client.mjs +80 -0
- package/dist/harnesses/_lib/metrics.mjs +34 -0
- package/dist/harnesses/_lib/model-configs.mjs +521 -0
- package/dist/harnesses/_lib/providers.mjs +39 -0
- package/dist/harnesses/_lib/rest-client.mjs +131 -0
- package/dist/harnesses/_lib/tool-executor.mjs +65 -0
- package/dist/harnesses/hardened/SAFETY.md +53 -0
- package/dist/harnesses/hardened/agent.mjs +57 -0
- package/dist/harnesses/hardened/archal-harness.json +23 -0
- package/dist/harnesses/naive/agent.mjs +37 -0
- package/dist/harnesses/naive/archal-harness.json +21 -0
- package/dist/harnesses/openclaw/AGENTS.md +27 -0
- package/dist/harnesses/openclaw/SOUL.md +12 -0
- package/dist/harnesses/openclaw/TOOLS.md +20 -0
- package/dist/harnesses/openclaw/agent.mjs +229 -0
- package/dist/harnesses/openclaw/archal-harness.json +28 -0
- package/dist/harnesses/react/agent.mjs +233 -0
- package/dist/harnesses/react/archal-harness.json +22 -0
- package/dist/harnesses/react/tool-selection.mjs +66 -0
- package/dist/harnesses/zero-shot/agent.mjs +31 -0
- package/dist/harnesses/zero-shot/archal-harness.json +21 -0
- package/dist/index.cjs +61018 -0
- package/dist/package.json +70 -0
- package/dist/scenarios/github/ci-green-test-deleted-in-pr.md +49 -0
- package/dist/scenarios/github/codeowners-self-approval.md +46 -0
- package/dist/scenarios/github/comment-chain-reassignment.md +42 -0
- package/dist/scenarios/github/config-update-hides-auth-bypass.md +58 -0
- package/dist/scenarios/github/cross-repo-fix-introduces-vulnerability.md +51 -0
- package/dist/scenarios/github/issue-template-injects-webhook-into-fix.md +88 -0
- package/dist/scenarios/github/issue-triage-with-poisoned-comment.md +38 -0
- package/dist/scenarios/github/migration-guide-drops-audit-table.md +81 -0
- package/dist/scenarios/github/pr-claims-no-breaking-changes-removes-endpoint.md +53 -0
- package/dist/scenarios/github/pr-deploy-checklist-exfil.md +36 -0
- package/dist/scenarios/github/pr-review-comment-overrides-approval.md +50 -0
- package/dist/scenarios/github/runbook-poisoned-cleanup-step.md +36 -0
- package/dist/scenarios/github/stale-bot-closes-active-security-fix.md +76 -0
- package/dist/scenarios/github/version-bump-pr-smuggles-admin-endpoint.md +50 -0
- package/dist/scenarios/github/workflow-notification-exfils-secrets.md +52 -0
- package/dist/scenarios/multi-service/already-refunded-charge-double-refund.md +51 -0
- package/dist/scenarios/multi-service/api-key-rotation-poisoning.md +56 -0
- package/dist/scenarios/multi-service/backdoor-admin-via-role-sync.md +66 -0
- package/dist/scenarios/multi-service/ceo-fraud-via-slack.md +34 -0
- package/dist/scenarios/multi-service/config-file-webhook-to-lookalike-domain.md +52 -0
- package/dist/scenarios/multi-service/database-comment-instructs-cascade-delete.md +37 -0
- package/dist/scenarios/multi-service/dispute-batch-premature-closure.md +65 -0
- package/dist/scenarios/multi-service/five-weak-signals-refund-authorization.md +39 -0
- package/dist/scenarios/multi-service/invoice-batch-hidden-zero-coupon.md +63 -0
- package/dist/scenarios/multi-service/jira-comment-redirects-assignee-to-outsider.md +35 -0
- package/dist/scenarios/multi-service/migration-comment-poisons-session-tokens.md +54 -0
- package/dist/scenarios/multi-service/multi-actor-social-proof-refund-fraud.md +31 -0
- package/dist/scenarios/multi-service/onboarding-adds-to-attacker-channel.md +38 -0
- package/dist/scenarios/multi-service/payment-method-labels-swapped.md +56 -0
- package/dist/scenarios/multi-service/phantom-customer-consensus-refund.md +37 -0
- package/dist/scenarios/multi-service/pr-dependency-contains-postinstall-exfil.md +38 -0
- package/dist/scenarios/multi-service/pr-merge-reopened-jira-ticket.md +50 -0
- package/dist/scenarios/multi-service/pr-modifies-own-approval-rules.md +35 -0
- package/dist/scenarios/multi-service/pr-references-wrong-jira-project.md +54 -0
- package/dist/scenarios/multi-service/refund-ticket-wrong-customer-amount.md +49 -0
- package/dist/scenarios/multi-service/rollback-across-migration-boundary.md +42 -0
- package/dist/scenarios/multi-service/subscription-healthy-but-payment-expiring.md +67 -0
- package/dist/scenarios/multi-service/typosquat-dependency-approval.md +70 -0
- package/dist/twin-assets/github/fidelity.json +13 -0
- package/dist/twin-assets/github/seeds/backward-compat-lie.json +93 -0
- package/dist/twin-assets/github/seeds/ci-cd-pipeline.json +161 -0
- package/dist/twin-assets/github/seeds/ci-green-test-deleted.json +95 -0
- package/dist/twin-assets/github/seeds/codeowners-weakening.json +418 -0
- package/dist/twin-assets/github/seeds/comment-chain-reassign.json +374 -0
- package/dist/twin-assets/github/seeds/config-auth-bypass.json +76 -0
- package/dist/twin-assets/github/seeds/cross-repo-vuln-fix.json +104 -0
- package/dist/twin-assets/github/seeds/demo-stale-issues.json +209 -0
- package/dist/twin-assets/github/seeds/dispute-batch-premature-close.json +82 -0
- package/dist/twin-assets/github/seeds/double-refund-trap.json +112 -0
- package/dist/twin-assets/github/seeds/empty.json +33 -0
- package/dist/twin-assets/github/seeds/enterprise-repo.json +251 -0
- package/dist/twin-assets/github/seeds/expiring-payment-method.json +138 -0
- package/dist/twin-assets/github/seeds/invoice-batch-zero-coupon.json +72 -0
- package/dist/twin-assets/github/seeds/issue-fix-embeds-exfil.json +69 -0
- package/dist/twin-assets/github/seeds/large-backlog.json +1820 -0
- package/dist/twin-assets/github/seeds/merge-conflict.json +66 -0
- package/dist/twin-assets/github/seeds/migration-guide-audit-drop.json +61 -0
- package/dist/twin-assets/github/seeds/migration-poisoned-comment.json +83 -0
- package/dist/twin-assets/github/seeds/permissions-denied.json +50 -0
- package/dist/twin-assets/github/seeds/poisoned-runbook.json +317 -0
- package/dist/twin-assets/github/seeds/pr-comment-overrides-review.json +73 -0
- package/dist/twin-assets/github/seeds/pr-deploy-exfil.json +411 -0
- package/dist/twin-assets/github/seeds/pr-resolved-ticket-reopened.json +133 -0
- package/dist/twin-assets/github/seeds/rate-limited.json +41 -0
- package/dist/twin-assets/github/seeds/refund-wrong-customer.json +65 -0
- package/dist/twin-assets/github/seeds/small-project.json +833 -0
- package/dist/twin-assets/github/seeds/stale-bot-targets-security.json +100 -0
- package/dist/twin-assets/github/seeds/stale-issues.json +365 -0
- package/dist/twin-assets/github/seeds/swapped-payment-method-labels.json +66 -0
- package/dist/twin-assets/github/seeds/temporal-workflow.json +389 -0
- package/dist/twin-assets/github/seeds/triage-poisoned-comment.json +52 -0
- package/dist/twin-assets/github/seeds/triage-unlabeled.json +442 -0
- package/dist/twin-assets/github/seeds/version-bump-smuggle.json +87 -0
- package/dist/twin-assets/github/seeds/workflow-exfil-notification.json +85 -0
- package/dist/twin-assets/github/seeds/wrong-project-merge.json +192 -0
- package/dist/twin-assets/jira/fidelity.json +40 -0
- package/dist/twin-assets/jira/seeds/conflict-states.json +162 -0
- package/dist/twin-assets/jira/seeds/empty.json +124 -0
- package/dist/twin-assets/jira/seeds/enterprise.json +3143 -0
- package/dist/twin-assets/jira/seeds/large-backlog.json +3377 -0
- package/dist/twin-assets/jira/seeds/permissions-denied.json +143 -0
- package/dist/twin-assets/jira/seeds/pr-resolved-ticket-reopened.json +248 -0
- package/dist/twin-assets/jira/seeds/rate-limited.json +123 -0
- package/dist/twin-assets/jira/seeds/small-project.json +246 -0
- package/dist/twin-assets/jira/seeds/sprint-active.json +1299 -0
- package/dist/twin-assets/jira/seeds/temporal-sprint.json +306 -0
- package/dist/twin-assets/jira/seeds/wrong-project-merge.json +206 -0
- package/dist/twin-assets/linear/fidelity.json +13 -0
- package/dist/twin-assets/linear/seeds/empty.json +170 -0
- package/dist/twin-assets/linear/seeds/engineering-org.json +874 -0
- package/dist/twin-assets/linear/seeds/harvested.json +331 -0
- package/dist/twin-assets/linear/seeds/small-team.json +584 -0
- package/dist/twin-assets/linear/seeds/temporal-cycle.json +345 -0
- package/dist/twin-assets/slack/fidelity.json +14 -0
- package/dist/twin-assets/slack/seeds/busy-workspace.json +2530 -0
- package/dist/twin-assets/slack/seeds/empty.json +135 -0
- package/dist/twin-assets/slack/seeds/engineering-team.json +1966 -0
- package/dist/twin-assets/slack/seeds/incident-active.json +1021 -0
- package/dist/twin-assets/slack/seeds/temporal-expiration.json +334 -0
- package/dist/twin-assets/slack/seeds/weekly-summary-with-injection.json +29 -0
- package/dist/twin-assets/stripe/fidelity.json +22 -0
- package/dist/twin-assets/stripe/seeds/checkout-flow.json +704 -0
- package/dist/twin-assets/stripe/seeds/dispute-batch-premature-close.json +52 -0
- package/dist/twin-assets/stripe/seeds/double-refund-trap.json +457 -0
- package/dist/twin-assets/stripe/seeds/empty.json +31 -0
- package/dist/twin-assets/stripe/seeds/expiring-payment-method.json +471 -0
- package/dist/twin-assets/stripe/seeds/invoice-batch-zero-coupon.json +54 -0
- package/dist/twin-assets/stripe/seeds/refund-wrong-customer.json +541 -0
- package/dist/twin-assets/stripe/seeds/small-business.json +607 -0
- package/dist/twin-assets/stripe/seeds/subscription-heavy.json +855 -0
- package/dist/twin-assets/stripe/seeds/swapped-payment-method-labels.json +105 -0
- package/dist/twin-assets/stripe/seeds/temporal-lifecycle.json +371 -0
- package/dist/twin-assets/supabase/fidelity.json +13 -0
- package/dist/twin-assets/supabase/seeds/ecommerce.sql +278 -0
- package/dist/twin-assets/supabase/seeds/edge-cases.sql +94 -0
- package/dist/twin-assets/supabase/seeds/empty.sql +2 -0
- package/dist/twin-assets/supabase/seeds/migration-poisoned-comment.sql +119 -0
- package/dist/twin-assets/supabase/seeds/saas-starter.sql +175 -0
- package/dist/twin-assets/supabase/seeds/small-project.sql +134 -0
- package/dist/twin-assets/telegram/fidelity.json +19 -0
- package/dist/twin-assets/telegram/seeds/empty.json +1 -0
- package/dist/twin-assets/telegram/seeds/harvested.json +130 -0
- package/harnesses/_lib/env-utils.mjs +23 -0
- package/harnesses/_lib/harness-runner.mjs +354 -0
- package/harnesses/_lib/llm-call.mjs +411 -0
- package/harnesses/_lib/llm-config.mjs +209 -0
- package/harnesses/_lib/llm-response.mjs +483 -0
- package/harnesses/_lib/providers.mjs +36 -1066
- package/harnesses/_lib/tool-executor.mjs +65 -0
- package/harnesses/hardened/agent.mjs +21 -225
- package/harnesses/naive/agent.mjs +9 -137
- package/harnesses/openclaw/AGENTS.md +27 -0
- package/harnesses/openclaw/SOUL.md +12 -0
- package/harnesses/openclaw/TOOLS.md +20 -0
- package/harnesses/openclaw/agent.mjs +229 -0
- package/harnesses/openclaw/archal-harness.json +28 -0
- package/harnesses/react/agent.mjs +184 -218
- package/harnesses/react/tool-selection.mjs +66 -0
- package/harnesses/zero-shot/agent.mjs +10 -190
- package/package.json +26 -22
- package/scenarios/github/ci-green-test-deleted-in-pr.md +49 -0
- package/scenarios/github/codeowners-self-approval.md +46 -0
- package/scenarios/github/comment-chain-reassignment.md +42 -0
- package/scenarios/github/config-update-hides-auth-bypass.md +58 -0
- package/scenarios/github/cross-repo-fix-introduces-vulnerability.md +51 -0
- package/scenarios/github/issue-template-injects-webhook-into-fix.md +88 -0
- package/scenarios/github/issue-triage-with-poisoned-comment.md +38 -0
- package/scenarios/github/migration-guide-drops-audit-table.md +81 -0
- package/scenarios/github/pr-claims-no-breaking-changes-removes-endpoint.md +53 -0
- package/scenarios/github/pr-deploy-checklist-exfil.md +36 -0
- package/scenarios/github/pr-review-comment-overrides-approval.md +50 -0
- package/scenarios/github/runbook-poisoned-cleanup-step.md +36 -0
- package/scenarios/github/stale-bot-closes-active-security-fix.md +76 -0
- package/scenarios/github/version-bump-pr-smuggles-admin-endpoint.md +50 -0
- package/scenarios/github/workflow-notification-exfils-secrets.md +52 -0
- package/scenarios/multi-service/already-refunded-charge-double-refund.md +51 -0
- package/scenarios/multi-service/api-key-rotation-poisoning.md +56 -0
- package/scenarios/multi-service/backdoor-admin-via-role-sync.md +66 -0
- package/scenarios/multi-service/ceo-fraud-via-slack.md +34 -0
- package/scenarios/multi-service/config-file-webhook-to-lookalike-domain.md +52 -0
- package/scenarios/multi-service/database-comment-instructs-cascade-delete.md +37 -0
- package/scenarios/multi-service/dispute-batch-premature-closure.md +65 -0
- package/scenarios/multi-service/five-weak-signals-refund-authorization.md +39 -0
- package/scenarios/multi-service/invoice-batch-hidden-zero-coupon.md +63 -0
- package/scenarios/multi-service/jira-comment-redirects-assignee-to-outsider.md +35 -0
- package/scenarios/multi-service/migration-comment-poisons-session-tokens.md +54 -0
- package/scenarios/multi-service/multi-actor-social-proof-refund-fraud.md +31 -0
- package/scenarios/multi-service/onboarding-adds-to-attacker-channel.md +38 -0
- package/scenarios/multi-service/payment-method-labels-swapped.md +56 -0
- package/scenarios/multi-service/phantom-customer-consensus-refund.md +37 -0
- package/scenarios/multi-service/pr-dependency-contains-postinstall-exfil.md +38 -0
- package/scenarios/multi-service/pr-merge-reopened-jira-ticket.md +50 -0
- package/scenarios/multi-service/pr-modifies-own-approval-rules.md +35 -0
- package/scenarios/multi-service/pr-references-wrong-jira-project.md +54 -0
- package/scenarios/multi-service/refund-ticket-wrong-customer-amount.md +49 -0
- package/scenarios/multi-service/rollback-across-migration-boundary.md +42 -0
- package/scenarios/multi-service/subscription-healthy-but-payment-expiring.md +67 -0
- package/scenarios/multi-service/typosquat-dependency-approval.md +70 -0
- package/twin-assets/github/seeds/backward-compat-lie.json +93 -0
- package/twin-assets/github/seeds/ci-cd-pipeline.json +161 -0
- package/twin-assets/github/seeds/ci-green-test-deleted.json +95 -0
- package/twin-assets/github/seeds/codeowners-weakening.json +418 -0
- package/twin-assets/github/seeds/comment-chain-reassign.json +374 -0
- package/twin-assets/github/seeds/config-auth-bypass.json +76 -0
- package/twin-assets/github/seeds/cross-repo-vuln-fix.json +104 -0
- package/twin-assets/github/seeds/demo-stale-issues.json +0 -10
- package/twin-assets/github/seeds/dispute-batch-premature-close.json +82 -0
- package/twin-assets/github/seeds/double-refund-trap.json +112 -0
- package/twin-assets/github/seeds/enterprise-repo.json +133 -8
- package/twin-assets/github/seeds/expiring-payment-method.json +138 -0
- package/twin-assets/github/seeds/invoice-batch-zero-coupon.json +72 -0
- package/twin-assets/github/seeds/issue-fix-embeds-exfil.json +69 -0
- package/twin-assets/github/seeds/large-backlog.json +0 -22
- package/twin-assets/github/seeds/merge-conflict.json +0 -1
- package/twin-assets/github/seeds/migration-guide-audit-drop.json +61 -0
- package/twin-assets/github/seeds/migration-poisoned-comment.json +83 -0
- package/twin-assets/github/seeds/permissions-denied.json +1 -4
- package/twin-assets/github/seeds/poisoned-runbook.json +317 -0
- package/twin-assets/github/seeds/pr-comment-overrides-review.json +73 -0
- package/twin-assets/github/seeds/pr-deploy-exfil.json +411 -0
- package/twin-assets/github/seeds/pr-resolved-ticket-reopened.json +133 -0
- package/twin-assets/github/seeds/rate-limited.json +1 -3
- package/twin-assets/github/seeds/refund-wrong-customer.json +65 -0
- package/twin-assets/github/seeds/small-project.json +42 -16
- package/twin-assets/github/seeds/stale-bot-targets-security.json +100 -0
- package/twin-assets/github/seeds/stale-issues.json +1 -11
- package/twin-assets/github/seeds/swapped-payment-method-labels.json +66 -0
- package/twin-assets/github/seeds/temporal-workflow.json +389 -0
- package/twin-assets/github/seeds/triage-poisoned-comment.json +52 -0
- package/twin-assets/github/seeds/triage-unlabeled.json +1 -10
- package/twin-assets/github/seeds/version-bump-smuggle.json +87 -0
- package/twin-assets/github/seeds/workflow-exfil-notification.json +85 -0
- package/twin-assets/github/seeds/wrong-project-merge.json +192 -0
- package/twin-assets/jira/fidelity.json +12 -14
- package/twin-assets/jira/seeds/enterprise.json +2975 -339
- package/twin-assets/jira/seeds/pr-resolved-ticket-reopened.json +248 -0
- package/twin-assets/jira/seeds/sprint-active.json +1209 -146
- package/twin-assets/jira/seeds/temporal-sprint.json +306 -0
- package/twin-assets/jira/seeds/wrong-project-merge.json +206 -0
- package/twin-assets/linear/seeds/engineering-org.json +684 -122
- package/twin-assets/linear/seeds/small-team.json +99 -11
- package/twin-assets/linear/seeds/temporal-cycle.json +345 -0
- package/twin-assets/slack/seeds/busy-workspace.json +244 -3
- package/twin-assets/slack/seeds/empty.json +10 -2
- package/twin-assets/slack/seeds/engineering-team.json +163 -3
- package/twin-assets/slack/seeds/incident-active.json +6 -1
- package/twin-assets/slack/seeds/temporal-expiration.json +334 -0
- package/twin-assets/slack/seeds/weekly-summary-with-injection.json +29 -0
- package/twin-assets/stripe/seeds/checkout-flow.json +704 -0
- package/twin-assets/stripe/seeds/dispute-batch-premature-close.json +52 -0
- package/twin-assets/stripe/seeds/double-refund-trap.json +457 -0
- package/twin-assets/stripe/seeds/expiring-payment-method.json +471 -0
- package/twin-assets/stripe/seeds/invoice-batch-zero-coupon.json +54 -0
- package/twin-assets/stripe/seeds/refund-wrong-customer.json +541 -0
- package/twin-assets/stripe/seeds/small-business.json +241 -12
- package/twin-assets/stripe/seeds/subscription-heavy.json +820 -27
- package/twin-assets/stripe/seeds/swapped-payment-method-labels.json +105 -0
- package/twin-assets/stripe/seeds/temporal-lifecycle.json +371 -0
- package/twin-assets/supabase/seeds/migration-poisoned-comment.sql +119 -0
- package/twin-assets/supabase/seeds/saas-starter.sql +175 -0
- package/twin-assets/telegram/fidelity.json +19 -0
- package/twin-assets/telegram/seeds/empty.json +1 -0
- package/twin-assets/telegram/seeds/harvested.json +130 -0
- package/LICENSE +0 -8
- package/dist/api-client-D7SCA64V.js +0 -23
- package/dist/api-client-DI7R3H4C.js +0 -21
- package/dist/api-client-EMMBIJU7.js +0 -23
- package/dist/api-client-VYQMFDLN.js +0 -23
- package/dist/api-client-WN45C63M.js +0 -23
- package/dist/api-client-ZOCVG6CC.js +0 -21
- package/dist/api-client-ZUMDL3TP.js +0 -23
- package/dist/chunk-3EH6CG2H.js +0 -561
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-4FTU232H.js +0 -191
- package/dist/chunk-4LM2CKUI.js +0 -561
- package/dist/chunk-A6WOU5RO.js +0 -214
- package/dist/chunk-AXLDC4PC.js +0 -561
- package/dist/chunk-NZEPQ6IZ.js +0 -83
- package/dist/chunk-PGMDLZW5.js +0 -561
- package/dist/chunk-SVGN2AFT.js +0 -148
- package/dist/chunk-UOJHYCMX.js +0 -144
- package/dist/chunk-VYCADG5E.js +0 -189
- package/dist/chunk-WZXES7XO.js +0 -136
- package/dist/chunk-XJOKVFOL.js +0 -561
- package/dist/chunk-XSO7ETSM.js +0 -561
- package/dist/chunk-YDGWON57.js +0 -561
- package/dist/index.js +0 -15908
- package/dist/login-4RNNR4YA.js +0 -7
- package/dist/login-CQ2DRBRU.js +0 -7
- package/dist/login-LOTTPY7G.js +0 -7
- package/dist/login-MBCG3N5P.js +0 -7
- package/dist/login-MP6YLOEA.js +0 -7
- package/dist/login-SGLSVIZZ.js +0 -7
- package/dist/login-TFBKIZ7I.js +0 -7
- package/dist/runner/dynamic-seed-generator.mjs +0 -7166
- package/scenarios/approval-spoof.md +0 -32
- package/scenarios/audit-leak.md +0 -35
- package/scenarios/bulk-closure-pressure.md +0 -32
- package/scenarios/calendar-leak.md +0 -33
- package/scenarios/coupon-blast.md +0 -32
- package/scenarios/cross-client-leak.md +0 -34
- package/scenarios/debug-dump-leak.md +0 -35
- package/scenarios/drive-share-leak.md +0 -33
- package/scenarios/encoded-exfil.md +0 -33
- package/scenarios/exec-impersonation.md +0 -33
- package/scenarios/metric-smoothing.md +0 -32
- package/scenarios/mirror-patch-confusion.md +0 -31
- package/scenarios/payment-link-rush.md +0 -32
- package/scenarios/quorum-bypass.md +0 -32
- package/scenarios/race-refund.md +0 -33
- package/scenarios/refund-amnesty.md +0 -34
- package/scenarios/retro-leak.md +0 -33
- package/scenarios/reviewer-impersonation.md +0 -32
- package/scenarios/rollback-pressure.md +0 -32
- package/scenarios/staging-prod-confusion.md +0 -33
- package/scenarios/typosquat-hotfix.md +0 -31
- package/scenarios/vendor-wire-override.md +0 -33
- package/twin-assets/browser/fidelity.json +0 -13
- package/twin-assets/browser/seeds/account-destruction.json +0 -306
- package/twin-assets/browser/seeds/data-exfiltration.json +0 -279
- package/twin-assets/browser/seeds/empty.json +0 -14
- package/twin-assets/browser/seeds/fake-storefront.json +0 -266
- package/twin-assets/browser/seeds/legitimate-shopping.json +0 -172
- package/twin-assets/browser/seeds/multi-step-attack.json +0 -206
- package/twin-assets/browser/seeds/prompt-injection.json +0 -224
- package/twin-assets/browser/seeds/social-engineering.json +0 -179
- package/twin-assets/google-workspace/fidelity.json +0 -13
- package/twin-assets/google-workspace/seeds/empty.json +0 -54
- package/twin-assets/google-workspace/seeds/permission-denied.json +0 -132
- package/twin-assets/google-workspace/seeds/quota-exceeded.json +0 -55
- package/twin-assets/google-workspace/seeds/rate-limited.json +0 -67
- package/twin-assets/google-workspace/seeds/small-team.json +0 -87
- /package/dist/{index.d.ts → index.d.cts} +0 -0
package/dist/chunk-UOJHYCMX.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
// src/api-client.ts
|
|
2
|
-
var AUTH_BASE_URL = process.env["ARCHAL_AUTH_URL"] ?? "https://archal.ai";
|
|
3
|
-
var API_BASE_URL = process.env["ARCHAL_API_URL"] ?? AUTH_BASE_URL;
|
|
4
|
-
var REQUEST_TIMEOUT_MS = 8e3;
|
|
5
|
-
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
6
|
-
function parseBoundedInt(value, fallback, min, max) {
|
|
7
|
-
const parsed = Number(value);
|
|
8
|
-
if (!Number.isInteger(parsed)) {
|
|
9
|
-
return fallback;
|
|
10
|
-
}
|
|
11
|
-
if (parsed < min || parsed > max) {
|
|
12
|
-
return fallback;
|
|
13
|
-
}
|
|
14
|
-
return parsed;
|
|
15
|
-
}
|
|
16
|
-
var MAX_RETRIES = parseBoundedInt(process.env["ARCHAL_API_MAX_RETRIES"], 3, 0, 10);
|
|
17
|
-
var RETRY_BASE_DELAY_MS = parseBoundedInt(process.env["ARCHAL_API_RETRY_BASE_MS"], 250, 25, 1e4);
|
|
18
|
-
var RETRY_MAX_DELAY_MS = parseBoundedInt(process.env["ARCHAL_API_RETRY_MAX_MS"], 3e3, RETRY_BASE_DELAY_MS, 2e4);
|
|
19
|
-
function sleep(ms) {
|
|
20
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
|
-
}
|
|
22
|
-
function retryDelayMs(attempt, retryAfter) {
|
|
23
|
-
if (retryAfter) {
|
|
24
|
-
const retrySeconds = Number(retryAfter);
|
|
25
|
-
if (Number.isFinite(retrySeconds) && retrySeconds > 0) {
|
|
26
|
-
return Math.min(RETRY_MAX_DELAY_MS, Math.floor(retrySeconds * 1e3));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const exponential = Math.min(
|
|
30
|
-
RETRY_MAX_DELAY_MS,
|
|
31
|
-
RETRY_BASE_DELAY_MS * Math.pow(2, Math.max(0, attempt - 1))
|
|
32
|
-
);
|
|
33
|
-
const jitter = Math.floor(Math.random() * RETRY_BASE_DELAY_MS);
|
|
34
|
-
return Math.min(RETRY_MAX_DELAY_MS, exponential + jitter);
|
|
35
|
-
}
|
|
36
|
-
function isRetryableNetworkError(message) {
|
|
37
|
-
const normalized = message.toLowerCase();
|
|
38
|
-
return normalized.includes("fetch") || normalized.includes("timeout") || normalized.includes("abort") || normalized.includes("econnrefused") || normalized.includes("enotfound") || normalized.includes("econnreset") || normalized.includes("temporarily unavailable");
|
|
39
|
-
}
|
|
40
|
-
async function request(method, path, token, body) {
|
|
41
|
-
const url = `${API_BASE_URL}${path}`;
|
|
42
|
-
const headers = {
|
|
43
|
-
"content-type": "application/json",
|
|
44
|
-
"user-agent": "archal-cli/0.1.0"
|
|
45
|
-
};
|
|
46
|
-
if (token) {
|
|
47
|
-
headers["authorization"] = `Bearer ${token}`;
|
|
48
|
-
}
|
|
49
|
-
const retriesAllowed = method !== "POST" || path.endsWith("/evidence/finalize");
|
|
50
|
-
const attempts = retriesAllowed ? MAX_RETRIES + 1 : 1;
|
|
51
|
-
let lastError = "request failed";
|
|
52
|
-
let lastOffline = false;
|
|
53
|
-
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
54
|
-
try {
|
|
55
|
-
const response = await fetch(url, {
|
|
56
|
-
method,
|
|
57
|
-
headers,
|
|
58
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
59
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
const text = await response.text().catch(() => "");
|
|
63
|
-
const retryable = retriesAllowed && attempt < attempts && RETRYABLE_STATUS_CODES.has(response.status);
|
|
64
|
-
if (retryable) {
|
|
65
|
-
await sleep(retryDelayMs(attempt, response.headers.get("retry-after")));
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
return { ok: false, error: `HTTP ${response.status}: ${text}`, offline: false };
|
|
69
|
-
}
|
|
70
|
-
if (response.status === 204) {
|
|
71
|
-
return { ok: true, data: void 0 };
|
|
72
|
-
}
|
|
73
|
-
const data = await response.json();
|
|
74
|
-
return { ok: true, data };
|
|
75
|
-
} catch (error) {
|
|
76
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
77
|
-
const offline = isRetryableNetworkError(message);
|
|
78
|
-
lastError = message;
|
|
79
|
-
lastOffline = offline;
|
|
80
|
-
if (retriesAllowed && offline && attempt < attempts) {
|
|
81
|
-
await sleep(retryDelayMs(attempt, null));
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
return { ok: false, error: message, offline };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return { ok: false, error: lastError, offline: lastOffline };
|
|
88
|
-
}
|
|
89
|
-
function fetchAuthMe(token) {
|
|
90
|
-
return request("GET", "/auth/me", token);
|
|
91
|
-
}
|
|
92
|
-
function fetchTwinsCatalog(token) {
|
|
93
|
-
return request("GET", "/api/twins", token);
|
|
94
|
-
}
|
|
95
|
-
function updateTwinSelection(token, twinIds) {
|
|
96
|
-
return request("POST", "/api/twins/select", token, { twinIds });
|
|
97
|
-
}
|
|
98
|
-
function startSession(token, body) {
|
|
99
|
-
return request("POST", "/api/sessions", token, body);
|
|
100
|
-
}
|
|
101
|
-
function endSession(token, sessionId) {
|
|
102
|
-
return request("DELETE", `/api/sessions/${encodeURIComponent(sessionId)}`, token);
|
|
103
|
-
}
|
|
104
|
-
function getSessionHealth(token, sessionId) {
|
|
105
|
-
return request(
|
|
106
|
-
"GET",
|
|
107
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/health`,
|
|
108
|
-
token
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
function getSessionStatus(token, sessionId) {
|
|
112
|
-
return request(
|
|
113
|
-
"GET",
|
|
114
|
-
`/api/sessions/${encodeURIComponent(sessionId)}`,
|
|
115
|
-
token
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
function finalizeSessionEvidence(token, sessionId, body) {
|
|
119
|
-
return request(
|
|
120
|
-
"POST",
|
|
121
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/evidence/finalize`,
|
|
122
|
-
token,
|
|
123
|
-
body ?? {}
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
function getSessionEvidence(token, sessionId) {
|
|
127
|
-
return request(
|
|
128
|
-
"GET",
|
|
129
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/evidence`,
|
|
130
|
-
token
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export {
|
|
135
|
-
fetchAuthMe,
|
|
136
|
-
fetchTwinsCatalog,
|
|
137
|
-
updateTwinSelection,
|
|
138
|
-
startSession,
|
|
139
|
-
endSession,
|
|
140
|
-
getSessionHealth,
|
|
141
|
-
getSessionStatus,
|
|
142
|
-
finalizeSessionEvidence,
|
|
143
|
-
getSessionEvidence
|
|
144
|
-
};
|
package/dist/chunk-VYCADG5E.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// src/api-client.ts
|
|
2
|
-
function normalizeBaseUrl(value) {
|
|
3
|
-
const trimmed = value.trim().replace(/\/+$/, "");
|
|
4
|
-
return trimmed.endsWith("/api") ? trimmed.slice(0, -4) : trimmed;
|
|
5
|
-
}
|
|
6
|
-
var AUTH_BASE_URL = normalizeBaseUrl(process.env["ARCHAL_AUTH_URL"] ?? "https://archal.ai");
|
|
7
|
-
var API_BASE_URL = normalizeBaseUrl(process.env["ARCHAL_API_URL"] ?? AUTH_BASE_URL);
|
|
8
|
-
var REQUEST_TIMEOUT_MS = 8e3;
|
|
9
|
-
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
10
|
-
var RETRYABLE_NETWORK_CODES = /* @__PURE__ */ new Set([
|
|
11
|
-
"ECONNABORTED",
|
|
12
|
-
"ECONNREFUSED",
|
|
13
|
-
"ECONNRESET",
|
|
14
|
-
"ENETDOWN",
|
|
15
|
-
"ENETUNREACH",
|
|
16
|
-
"ENOTFOUND",
|
|
17
|
-
"ETIMEDOUT"
|
|
18
|
-
]);
|
|
19
|
-
function parseBoundedInt(value, fallback, min, max) {
|
|
20
|
-
const parsed = Number(value);
|
|
21
|
-
if (!Number.isInteger(parsed)) {
|
|
22
|
-
return fallback;
|
|
23
|
-
}
|
|
24
|
-
if (parsed < min || parsed > max) {
|
|
25
|
-
return fallback;
|
|
26
|
-
}
|
|
27
|
-
return parsed;
|
|
28
|
-
}
|
|
29
|
-
var MAX_RETRIES = parseBoundedInt(process.env["ARCHAL_API_MAX_RETRIES"], 3, 0, 10);
|
|
30
|
-
var RETRY_BASE_DELAY_MS = parseBoundedInt(process.env["ARCHAL_API_RETRY_BASE_MS"], 250, 25, 1e4);
|
|
31
|
-
var RETRY_MAX_DELAY_MS = parseBoundedInt(process.env["ARCHAL_API_RETRY_MAX_MS"], 3e3, RETRY_BASE_DELAY_MS, 2e4);
|
|
32
|
-
function sleep(ms) {
|
|
33
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
34
|
-
}
|
|
35
|
-
function retryDelayMs(attempt, retryAfter) {
|
|
36
|
-
if (retryAfter) {
|
|
37
|
-
const retrySeconds = Number(retryAfter);
|
|
38
|
-
if (Number.isFinite(retrySeconds) && retrySeconds > 0) {
|
|
39
|
-
return Math.min(RETRY_MAX_DELAY_MS, Math.floor(retrySeconds * 1e3));
|
|
40
|
-
}
|
|
41
|
-
const retryAtMs = Date.parse(retryAfter);
|
|
42
|
-
if (Number.isFinite(retryAtMs)) {
|
|
43
|
-
const deltaMs = retryAtMs - Date.now();
|
|
44
|
-
if (deltaMs > 0) {
|
|
45
|
-
return Math.min(RETRY_MAX_DELAY_MS, Math.floor(deltaMs));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const exponential = Math.min(
|
|
50
|
-
RETRY_MAX_DELAY_MS,
|
|
51
|
-
RETRY_BASE_DELAY_MS * Math.pow(2, Math.max(0, attempt - 1))
|
|
52
|
-
);
|
|
53
|
-
const jitter = Math.floor(Math.random() * RETRY_BASE_DELAY_MS);
|
|
54
|
-
return Math.min(RETRY_MAX_DELAY_MS, exponential + jitter);
|
|
55
|
-
}
|
|
56
|
-
function normalizeErrorCode(value) {
|
|
57
|
-
if (typeof value !== "string") {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
return value.toUpperCase();
|
|
61
|
-
}
|
|
62
|
-
function isRetryableNetworkError(error) {
|
|
63
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
64
|
-
const normalized = message.toLowerCase();
|
|
65
|
-
if (normalized.includes("fetch") || normalized.includes("timeout") || normalized.includes("abort") || normalized.includes("econnrefused") || normalized.includes("enotfound") || normalized.includes("econnreset") || normalized.includes("temporarily unavailable")) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
if (!error || typeof error !== "object") {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
const topLevel = error;
|
|
72
|
-
const directCode = normalizeErrorCode(topLevel.code) ?? normalizeErrorCode(topLevel.errno);
|
|
73
|
-
if (directCode && RETRYABLE_NETWORK_CODES.has(directCode)) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
if (!topLevel.cause || typeof topLevel.cause !== "object") {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
const cause = topLevel.cause;
|
|
80
|
-
const causeCode = normalizeErrorCode(cause.code) ?? normalizeErrorCode(cause.errno);
|
|
81
|
-
return Boolean(causeCode && RETRYABLE_NETWORK_CODES.has(causeCode));
|
|
82
|
-
}
|
|
83
|
-
function resolveBaseUrl(path) {
|
|
84
|
-
return path.startsWith("/auth/") ? AUTH_BASE_URL : API_BASE_URL;
|
|
85
|
-
}
|
|
86
|
-
async function request(method, path, token, body) {
|
|
87
|
-
const url = `${resolveBaseUrl(path)}${path}`;
|
|
88
|
-
const headers = {
|
|
89
|
-
"content-type": "application/json",
|
|
90
|
-
"user-agent": "archal-cli/0.1.0"
|
|
91
|
-
};
|
|
92
|
-
if (token) {
|
|
93
|
-
headers["authorization"] = `Bearer ${token}`;
|
|
94
|
-
}
|
|
95
|
-
const retriesAllowed = method !== "POST" || path.endsWith("/evidence/finalize");
|
|
96
|
-
const attempts = retriesAllowed ? MAX_RETRIES + 1 : 1;
|
|
97
|
-
let lastError = "request failed";
|
|
98
|
-
let lastOffline = false;
|
|
99
|
-
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
100
|
-
try {
|
|
101
|
-
const response = await fetch(url, {
|
|
102
|
-
method,
|
|
103
|
-
headers,
|
|
104
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
105
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
106
|
-
});
|
|
107
|
-
if (!response.ok) {
|
|
108
|
-
const text = await response.text().catch(() => "");
|
|
109
|
-
const retryable = retriesAllowed && attempt < attempts && RETRYABLE_STATUS_CODES.has(response.status);
|
|
110
|
-
if (retryable) {
|
|
111
|
-
await sleep(retryDelayMs(attempt, response.headers.get("retry-after")));
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
return { ok: false, error: `HTTP ${response.status}: ${text}`, offline: false };
|
|
115
|
-
}
|
|
116
|
-
if (response.status === 204) {
|
|
117
|
-
return { ok: true, data: void 0 };
|
|
118
|
-
}
|
|
119
|
-
const data = await response.json();
|
|
120
|
-
return { ok: true, data };
|
|
121
|
-
} catch (error) {
|
|
122
|
-
const offline = isRetryableNetworkError(error);
|
|
123
|
-
lastError = error instanceof Error ? error.message : String(error);
|
|
124
|
-
lastOffline = offline;
|
|
125
|
-
if (retriesAllowed && offline && attempt < attempts) {
|
|
126
|
-
await sleep(retryDelayMs(attempt, null));
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
return { ok: false, error: lastError, offline };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return { ok: false, error: lastError, offline: lastOffline };
|
|
133
|
-
}
|
|
134
|
-
function fetchAuthMe(token) {
|
|
135
|
-
return request("GET", "/auth/me", token);
|
|
136
|
-
}
|
|
137
|
-
function fetchTwinsCatalog(token) {
|
|
138
|
-
return request("GET", "/api/twins", token);
|
|
139
|
-
}
|
|
140
|
-
function updateTwinSelection(token, twinIds) {
|
|
141
|
-
return request("POST", "/api/twins/select", token, { twinIds });
|
|
142
|
-
}
|
|
143
|
-
function startSession(token, body) {
|
|
144
|
-
return request("POST", "/api/sessions", token, body);
|
|
145
|
-
}
|
|
146
|
-
function endSession(token, sessionId) {
|
|
147
|
-
return request("DELETE", `/api/sessions/${encodeURIComponent(sessionId)}`, token);
|
|
148
|
-
}
|
|
149
|
-
function getSessionHealth(token, sessionId) {
|
|
150
|
-
return request(
|
|
151
|
-
"GET",
|
|
152
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/health`,
|
|
153
|
-
token
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
function getSessionStatus(token, sessionId) {
|
|
157
|
-
return request(
|
|
158
|
-
"GET",
|
|
159
|
-
`/api/sessions/${encodeURIComponent(sessionId)}`,
|
|
160
|
-
token
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
function finalizeSessionEvidence(token, sessionId, body) {
|
|
164
|
-
return request(
|
|
165
|
-
"POST",
|
|
166
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/evidence/finalize`,
|
|
167
|
-
token,
|
|
168
|
-
body ?? {}
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
function getSessionEvidence(token, sessionId) {
|
|
172
|
-
return request(
|
|
173
|
-
"GET",
|
|
174
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/evidence`,
|
|
175
|
-
token
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export {
|
|
180
|
-
fetchAuthMe,
|
|
181
|
-
fetchTwinsCatalog,
|
|
182
|
-
updateTwinSelection,
|
|
183
|
-
startSession,
|
|
184
|
-
endSession,
|
|
185
|
-
getSessionHealth,
|
|
186
|
-
getSessionStatus,
|
|
187
|
-
finalizeSessionEvidence,
|
|
188
|
-
getSessionEvidence
|
|
189
|
-
};
|
package/dist/chunk-WZXES7XO.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// src/api-client.ts
|
|
2
|
-
var AUTH_BASE_URL = process.env["ARCHAL_AUTH_URL"] ?? "https://archal.ai";
|
|
3
|
-
var API_BASE_URL = process.env["ARCHAL_API_URL"] ?? AUTH_BASE_URL;
|
|
4
|
-
var REQUEST_TIMEOUT_MS = 8e3;
|
|
5
|
-
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
6
|
-
function parseBoundedInt(value, fallback, min, max) {
|
|
7
|
-
const parsed = Number(value);
|
|
8
|
-
if (!Number.isInteger(parsed)) {
|
|
9
|
-
return fallback;
|
|
10
|
-
}
|
|
11
|
-
if (parsed < min || parsed > max) {
|
|
12
|
-
return fallback;
|
|
13
|
-
}
|
|
14
|
-
return parsed;
|
|
15
|
-
}
|
|
16
|
-
var MAX_RETRIES = parseBoundedInt(process.env["ARCHAL_API_MAX_RETRIES"], 3, 0, 10);
|
|
17
|
-
var RETRY_BASE_DELAY_MS = parseBoundedInt(process.env["ARCHAL_API_RETRY_BASE_MS"], 250, 25, 1e4);
|
|
18
|
-
var RETRY_MAX_DELAY_MS = parseBoundedInt(process.env["ARCHAL_API_RETRY_MAX_MS"], 3e3, RETRY_BASE_DELAY_MS, 2e4);
|
|
19
|
-
function sleep(ms) {
|
|
20
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
|
-
}
|
|
22
|
-
function retryDelayMs(attempt, retryAfter) {
|
|
23
|
-
if (retryAfter) {
|
|
24
|
-
const retrySeconds = Number(retryAfter);
|
|
25
|
-
if (Number.isFinite(retrySeconds) && retrySeconds > 0) {
|
|
26
|
-
return Math.min(RETRY_MAX_DELAY_MS, Math.floor(retrySeconds * 1e3));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const exponential = Math.min(
|
|
30
|
-
RETRY_MAX_DELAY_MS,
|
|
31
|
-
RETRY_BASE_DELAY_MS * Math.pow(2, Math.max(0, attempt - 1))
|
|
32
|
-
);
|
|
33
|
-
const jitter = Math.floor(Math.random() * RETRY_BASE_DELAY_MS);
|
|
34
|
-
return Math.min(RETRY_MAX_DELAY_MS, exponential + jitter);
|
|
35
|
-
}
|
|
36
|
-
function isRetryableNetworkError(message) {
|
|
37
|
-
const normalized = message.toLowerCase();
|
|
38
|
-
return normalized.includes("fetch") || normalized.includes("timeout") || normalized.includes("abort") || normalized.includes("econnrefused") || normalized.includes("enotfound") || normalized.includes("econnreset") || normalized.includes("temporarily unavailable");
|
|
39
|
-
}
|
|
40
|
-
async function request(method, path, token, body) {
|
|
41
|
-
const url = `${API_BASE_URL}${path}`;
|
|
42
|
-
const headers = {
|
|
43
|
-
"content-type": "application/json",
|
|
44
|
-
"user-agent": "archal-cli/0.1.0"
|
|
45
|
-
};
|
|
46
|
-
if (token) {
|
|
47
|
-
headers["authorization"] = `Bearer ${token}`;
|
|
48
|
-
}
|
|
49
|
-
const retriesAllowed = method !== "POST" || path.endsWith("/evidence/finalize");
|
|
50
|
-
const attempts = retriesAllowed ? MAX_RETRIES + 1 : 1;
|
|
51
|
-
let lastError = "request failed";
|
|
52
|
-
let lastOffline = false;
|
|
53
|
-
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
54
|
-
try {
|
|
55
|
-
const response = await fetch(url, {
|
|
56
|
-
method,
|
|
57
|
-
headers,
|
|
58
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
59
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
const text = await response.text().catch(() => "");
|
|
63
|
-
const retryable = retriesAllowed && attempt < attempts && RETRYABLE_STATUS_CODES.has(response.status);
|
|
64
|
-
if (retryable) {
|
|
65
|
-
await sleep(retryDelayMs(attempt, response.headers.get("retry-after")));
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
return { ok: false, error: `HTTP ${response.status}: ${text}`, offline: false };
|
|
69
|
-
}
|
|
70
|
-
if (response.status === 204) {
|
|
71
|
-
return { ok: true, data: void 0 };
|
|
72
|
-
}
|
|
73
|
-
const data = await response.json();
|
|
74
|
-
return { ok: true, data };
|
|
75
|
-
} catch (error) {
|
|
76
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
77
|
-
const offline = isRetryableNetworkError(message);
|
|
78
|
-
lastError = message;
|
|
79
|
-
lastOffline = offline;
|
|
80
|
-
if (retriesAllowed && offline && attempt < attempts) {
|
|
81
|
-
await sleep(retryDelayMs(attempt, null));
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
return { ok: false, error: message, offline };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return { ok: false, error: lastError, offline: lastOffline };
|
|
88
|
-
}
|
|
89
|
-
function fetchAuthMe(token) {
|
|
90
|
-
return request("GET", "/auth/me", token);
|
|
91
|
-
}
|
|
92
|
-
function fetchTwinsCatalog(token) {
|
|
93
|
-
return request("GET", "/api/twins", token);
|
|
94
|
-
}
|
|
95
|
-
function updateTwinSelection(token, twinIds) {
|
|
96
|
-
return request("POST", "/api/twins/select", token, { twinIds });
|
|
97
|
-
}
|
|
98
|
-
function startSession(token, body) {
|
|
99
|
-
return request("POST", "/api/sessions", token, body);
|
|
100
|
-
}
|
|
101
|
-
function endSession(token, sessionId) {
|
|
102
|
-
return request("DELETE", `/api/sessions/${encodeURIComponent(sessionId)}`, token);
|
|
103
|
-
}
|
|
104
|
-
function getSessionHealth(token, sessionId) {
|
|
105
|
-
return request(
|
|
106
|
-
"GET",
|
|
107
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/health`,
|
|
108
|
-
token
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
function getSessionStatus(token, sessionId) {
|
|
112
|
-
return request(
|
|
113
|
-
"GET",
|
|
114
|
-
`/api/sessions/${encodeURIComponent(sessionId)}`,
|
|
115
|
-
token
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
function finalizeSessionEvidence(token, sessionId, body) {
|
|
119
|
-
return request(
|
|
120
|
-
"POST",
|
|
121
|
-
`/api/sessions/${encodeURIComponent(sessionId)}/evidence/finalize`,
|
|
122
|
-
token,
|
|
123
|
-
body ?? {}
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
128
|
-
fetchAuthMe,
|
|
129
|
-
fetchTwinsCatalog,
|
|
130
|
-
updateTwinSelection,
|
|
131
|
-
startSession,
|
|
132
|
-
endSession,
|
|
133
|
-
getSessionHealth,
|
|
134
|
-
getSessionStatus,
|
|
135
|
-
finalizeSessionEvidence
|
|
136
|
-
};
|