agenttwin 0.1.0 → 0.2.1

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.
Files changed (121) hide show
  1. package/README.md +94 -24
  2. package/dist/api.js +712 -0
  3. package/dist/cli.js +5375 -57
  4. package/dist/dashboard/assets/brand.css +2 -0
  5. package/dist/dashboard/assets/dashboard/dashboard.css +189 -0
  6. package/dist/dashboard/assets/dashboard/dashboard.js +438 -0
  7. package/dist/dashboard/assets/dashboard/hosted.js +50 -0
  8. package/dist/dashboard/assets/dashboard/inventory.json +1 -0
  9. package/dist/dashboard/assets/dashboard/runs.json +1 -0
  10. package/dist/dashboard/assets/fonts/Syne-OFL.txt +93 -0
  11. package/dist/dashboard/assets/fonts/inter-var.woff2 +0 -0
  12. package/dist/dashboard/assets/fonts/plexmono-400.woff2 +0 -0
  13. package/dist/dashboard/assets/fonts/plexmono-500.woff2 +0 -0
  14. package/dist/dashboard/assets/fonts/syne-400.ttf +0 -0
  15. package/dist/dashboard/assets/fonts/syne-500.ttf +0 -0
  16. package/dist/dashboard/assets/fonts/syne-600.ttf +0 -0
  17. package/dist/dashboard/assets/icons/ATTRIBUTION.md +7 -0
  18. package/dist/dashboard/assets/icons/attio.ico +0 -0
  19. package/dist/dashboard/assets/icons/aws.svg +1 -0
  20. package/dist/dashboard/assets/icons/bank.svg +5 -0
  21. package/dist/dashboard/assets/icons/box.svg +1 -0
  22. package/dist/dashboard/assets/icons/chat.svg +3 -0
  23. package/dist/dashboard/assets/icons/check.png +0 -0
  24. package/dist/dashboard/assets/icons/ci.svg +5 -0
  25. package/dist/dashboard/assets/icons/clay.png +0 -0
  26. package/dist/dashboard/assets/icons/cloudflare.svg +1 -0
  27. package/dist/dashboard/assets/icons/co-abridge.png +0 -0
  28. package/dist/dashboard/assets/icons/co-clay.png +0 -0
  29. package/dist/dashboard/assets/icons/co-cognition.png +0 -0
  30. package/dist/dashboard/assets/icons/co-intercom.svg +1 -0
  31. package/dist/dashboard/assets/icons/co-paloalto.png +0 -0
  32. package/dist/dashboard/assets/icons/co-pylon.png +0 -0
  33. package/dist/dashboard/assets/icons/co-ramp.png +0 -0
  34. package/dist/dashboard/assets/icons/co-sentry.svg +1 -0
  35. package/dist/dashboard/assets/icons/codes.svg +5 -0
  36. package/dist/dashboard/assets/icons/datadog.svg +1 -0
  37. package/dist/dashboard/assets/icons/discord.svg +1 -0
  38. package/dist/dashboard/assets/icons/docker.svg +1 -0
  39. package/dist/dashboard/assets/icons/documenso.png +0 -0
  40. package/dist/dashboard/assets/icons/dropbox.svg +1 -0
  41. package/dist/dashboard/assets/icons/edr.svg +4 -0
  42. package/dist/dashboard/assets/icons/ehr.svg +5 -0
  43. package/dist/dashboard/assets/icons/git.svg +1 -0
  44. package/dist/dashboard/assets/icons/github.svg +1 -0
  45. package/dist/dashboard/assets/icons/githubactions.svg +1 -0
  46. package/dist/dashboard/assets/icons/gitlab.svg +1 -0
  47. package/dist/dashboard/assets/icons/gmail.svg +7 -0
  48. package/dist/dashboard/assets/icons/google-calendar.svg +28 -0
  49. package/dist/dashboard/assets/icons/google.svg +1 -0
  50. package/dist/dashboard/assets/icons/googlecloud.svg +1 -0
  51. package/dist/dashboard/assets/icons/googledocs.svg +1 -0
  52. package/dist/dashboard/assets/icons/googledrive.svg +1 -0
  53. package/dist/dashboard/assets/icons/googlesheets.svg +1 -0
  54. package/dist/dashboard/assets/icons/hubspot.svg +1 -0
  55. package/dist/dashboard/assets/icons/intercom.svg +1 -0
  56. package/dist/dashboard/assets/icons/jira.svg +1 -0
  57. package/dist/dashboard/assets/icons/klaviyo.png +0 -0
  58. package/dist/dashboard/assets/icons/kubernetes.svg +1 -0
  59. package/dist/dashboard/assets/icons/linear.svg +1 -0
  60. package/dist/dashboard/assets/icons/linkedin.svg +1 -0
  61. package/dist/dashboard/assets/icons/mail.svg +4 -0
  62. package/dist/dashboard/assets/icons/mixpanel.svg +1 -0
  63. package/dist/dashboard/assets/icons/mongodb.svg +1 -0
  64. package/dist/dashboard/assets/icons/netsuite.png +0 -0
  65. package/dist/dashboard/assets/icons/nodedotjs.svg +1 -0
  66. package/dist/dashboard/assets/icons/notes.svg +5 -0
  67. package/dist/dashboard/assets/icons/notion.svg +1 -0
  68. package/dist/dashboard/assets/icons/npm.svg +1 -0
  69. package/dist/dashboard/assets/icons/okta.svg +1 -0
  70. package/dist/dashboard/assets/icons/openai.svg +1 -0
  71. package/dist/dashboard/assets/icons/outlook.ico +0 -0
  72. package/dist/dashboard/assets/icons/pagerduty.svg +1 -0
  73. package/dist/dashboard/assets/icons/policy.svg +5 -0
  74. package/dist/dashboard/assets/icons/postgres.svg +1 -0
  75. package/dist/dashboard/assets/icons/python.svg +1 -0
  76. package/dist/dashboard/assets/icons/quickbooks.svg +1 -0
  77. package/dist/dashboard/assets/icons/redis.svg +1 -0
  78. package/dist/dashboard/assets/icons/resend.svg +1 -0
  79. package/dist/dashboard/assets/icons/salesforce.svg +1 -0
  80. package/dist/dashboard/assets/icons/sentry.svg +1 -0
  81. package/dist/dashboard/assets/icons/shopify.svg +1 -0
  82. package/dist/dashboard/assets/icons/siem.svg +4 -0
  83. package/dist/dashboard/assets/icons/slack.svg +6 -0
  84. package/dist/dashboard/assets/icons/snowflake.svg +1 -0
  85. package/dist/dashboard/assets/icons/sparkle.svg +4 -0
  86. package/dist/dashboard/assets/icons/stripe.svg +1 -0
  87. package/dist/dashboard/assets/icons/supabase.svg +1 -0
  88. package/dist/dashboard/assets/icons/terraform.svg +1 -0
  89. package/dist/dashboard/assets/icons/trolley.ico +0 -0
  90. package/dist/dashboard/assets/icons/twilio.svg +1 -0
  91. package/dist/dashboard/assets/icons/ui/arrow-right.svg +1 -0
  92. package/dist/dashboard/assets/icons/ui/arrows-clockwise.svg +1 -0
  93. package/dist/dashboard/assets/icons/ui/arrows-left-right.svg +1 -0
  94. package/dist/dashboard/assets/icons/ui/caret-down.svg +1 -0
  95. package/dist/dashboard/assets/icons/ui/check.svg +1 -0
  96. package/dist/dashboard/assets/icons/ui/clock.svg +1 -0
  97. package/dist/dashboard/assets/icons/ui/cube.svg +1 -0
  98. package/dist/dashboard/assets/icons/ui/git-branch.svg +1 -0
  99. package/dist/dashboard/assets/icons/ui/github-logo.svg +1 -0
  100. package/dist/dashboard/assets/icons/ui/magnifying-glass.svg +1 -0
  101. package/dist/dashboard/assets/icons/ui/plugs-connected.svg +1 -0
  102. package/dist/dashboard/assets/icons/ui/seal-check.svg +1 -0
  103. package/dist/dashboard/assets/icons/ui/shield-check.svg +1 -0
  104. package/dist/dashboard/assets/icons/ui/stack-simple.svg +1 -0
  105. package/dist/dashboard/assets/icons/ui/terminal.svg +1 -0
  106. package/dist/dashboard/assets/icons/ui/warning-circle.svg +1 -0
  107. package/dist/dashboard/assets/icons/ui/x.svg +1 -0
  108. package/dist/dashboard/assets/icons/unified.png +0 -0
  109. package/dist/dashboard/assets/icons/unified.svg +23 -0
  110. package/dist/dashboard/assets/icons/unstructured.svg +3 -0
  111. package/dist/dashboard/assets/icons/vercel.svg +1 -0
  112. package/dist/dashboard/assets/icons/waterfall.jpg +0 -0
  113. package/dist/dashboard/assets/icons/xero.svg +1 -0
  114. package/dist/dashboard/assets/logo/favicon.svg +7 -0
  115. package/dist/dashboard/assets/logo/mark-stacked-worlds.svg +4 -0
  116. package/dist/dashboard/assets/logo/mark-twin-rings.svg +7 -0
  117. package/dist/dashboard/assets/logo/mark-worlds-overlap.svg +10 -0
  118. package/dist/dashboard/index.html +63 -0
  119. package/dist/gateway.js +719 -0
  120. package/dist/worker.js +341 -0
  121. package/package.json +8 -3
package/README.md CHANGED
@@ -1,48 +1,118 @@
1
- # agenttwin
1
+ # AgentTwin
2
2
 
3
- **Give your agent a test world before it touches the real one.**
3
+ Discover a project's dependencies, then run an explicitly configured Node workflow in a fresh hosted sandbox with stateful service adapters, faults and final-state checks.
4
4
 
5
- A safe, executable copy of the systems your agent reads from and writes to, so you
6
- can run the same workflow against a replica, inject real failure conditions, and
7
- turn a discovered failure into a regression test.
5
+ AgentTwin 0.2.0 executes application code in E2B. No local application containers are required. The E2B key belongs to the runtime operator; users of the hosted API receive separate revocable AgentTwin tokens.
8
6
 
9
- > **Early preview.** This package is the CLI shell for that vision. `agenttwin init`
10
- > works today. The runtime commands (`up`, `run`, `fault`, `diff`, `adopt`) are
11
- > coming soon.
7
+ ## Install and discover
12
8
 
13
- ## Usage
9
+ Node.js 22+ is required. Run discovery from your project; npx installs the CLI automatically:
14
10
 
15
11
  ```sh
16
12
  npx agenttwin init
13
+ npx agenttwin example --out ./agenttwin-example
17
14
  ```
18
15
 
19
- Writes a starter `agenttwin.config.json` into the current directory:
16
+ `init` writes the inventory, workflow candidates, `agenttwin.config.json`, `ENVIRONMENT.md`, `REPLICATION.md`, and an offline browser report. Discovery is evidence, not an automatically executable environment. It never uploads source. `init --json --dry-run` writes nothing.
17
+
18
+ ## Run through an AgentTwin API
19
+
20
+ Your operator supplies the API URL and your individual token:
21
+
22
+ ```sh
23
+ export AGENTTWIN_API_URL=https://your-agenttwin-api.example.com
24
+ export AGENTTWIN_TOKEN=your_individual_token
25
+ npx agenttwin run --file agenttwin-example/agenttwin.world.json
26
+ npx agenttwin run --file agenttwin-example/safe.world.json
27
+ ```
28
+
29
+ The first run should fail: a write commits but its response is delayed, and an unsafe retry creates two tickets. The safe version reuses an idempotency key and passes. Both execute real application code against a custom ticket API and a bounded Slack adapter. Every run starts from fresh seeds and credentials, then deletes its sandbox. These are examples you can replace, not a refund-specific product.
30
+
31
+ `run --json` emits a receipt with source/spec hashes, application output, ordered service events, initial/final service state, assertions, fault activation and sandbox metadata. Evidence stays in `.agenttwin/runs/`. Exit codes: 0 passed; 1 failed/error; 2 incomplete/blocked; 3 invalid input. An unsupported adapter operation or an untriggered requested fault makes the run incomplete.
32
+
33
+ ## Use your own E2B account
34
+
35
+ ```sh
36
+ export E2B_API_KEY=your_key
37
+ npx agenttwin setup
38
+ npx agenttwin run --runtime e2b --file agenttwin-example/safe.world.json
39
+ ```
40
+
41
+ `setup` builds a Node 22/PostgreSQL 15/Redis template on E2B and stores its nonsecret ID in `~/.agenttwin/runtime.json`. `E2B_TEMPLATE_ID` overrides that ID. It creates no local Docker containers. Sandboxes are created only for runs. The runtime boundary permits adding another hosted provider later; only E2B is implemented today.
42
+
43
+ ## Run your code
44
+
45
+ Edit a world JSON file, listing only the built application files to upload. Bundle npm dependencies before the run; the sandbox has no outbound internet and performs no npm install. `command` is an argv array starting with `node`; the app runs as uid 1000. A world file resolves its application files relative to its own directory. Optional `workflowId` links to a workflow in the current discovery inventory.
46
+
47
+ Use the generated `AGENTTWIN_<SERVICE>_URL` and `AGENTTWIN_<SERVICE>_TOKEN` values to configure your test clients. Production accounts, OAuth sessions, `.env` files and host credentials are not copied. Tokens and service state are fresh per run. Source files may contain hardcoded secrets; review the explicit upload list and bundle before uploading it.
48
+
49
+ Supported now:
50
+
51
+ - Generic JSON collections: GET/list, POST/create, seed records, bearer authentication and same-key idempotency replay/conflict. This is a custom API contract, not a CRM vendor clone.
52
+ - Slack subset: `chat.postMessage` with channel/text, `conversations.list` without parameters, `conversations.history` with channel. JSON and form POSTs are supported; reads also accept GET. Unknown methods or parameters fail visibly. OAuth, pagination, threads, files and complete SDK/provider parity are not supported.
53
+ - Real PostgreSQL 15: optional seed SQL, generated `DATABASE_URL`, read-only SELECT final-state assertions.
54
+ - Real Redis: generated `REDIS_URL`/`REDISCLI_AUTH`, string-key final-state assertions.
55
+ - One fault: a committed HTTP write followed by a delayed response. State count/filter assertions, DB rows and Redis values can verify side effects.
56
+
57
+ There is no automatic cloning of arbitrary software, provider account provisioning, complete vendor catalog, browser workflow runtime, coordinated snapshots, replay of LLM responses or automatic regression-code generation. Receipts verify the configured assertions, not complete production equivalence or adversarial program correctness.
58
+
59
+ ## Discovery and reports
60
+
61
+ `discover`, `decide`, `plan`, `status`, `inspect`, `grant`, `schema`, `export`, `report`, and `feedback` remain available. `--json` sends results to stdout and logs to stderr. Discovery inspects files and bounded commands; remote reads require scoped grants. `--probe` explicitly requests provider reads. Local application observation and the legacy refund `demo/trial/check/reset` commands are retired in the public CLI; use hosted `run` instead. Development unit tests still exercise adapter code locally.
62
+
63
+ ## Operate the API
64
+
65
+ The package includes `dist/gateway.js`. Deploy it on a server with Node 22+, HTTPS ingress and persistent disk. See the repository's `docs/HOSTED-RUNTIME.md` for deployment, accounts, limits and operational boundaries. The gateway is a control plane; applications execute in separate E2B sandboxes.
66
+
67
+ MIT license.
68
+
69
+ ## Discovery dashboard
70
+
71
+ `agenttwin init --yes` detects project dependencies, tooling and available connector configuration, then writes `.agenttwin/dashboard/index.html`. Open that file to review the detected environment without selecting every connector or uploading inventory. The dashboard includes its assets and an allowlisted discovery payload; account records, credential values and evidence paths are excluded. It starts with no saved run receipts. Detection does not verify provider access or implement an adapter.
72
+
73
+ For this repository’s website preview (`python3 serve.py 4173`), the dashboard automatically loads the latest handoff from init every five seconds while visible. Other projects use their generated dashboard or the manual discovery import. No inventory is uploaded to a hosted website automatically. Removed detected resources stay excluded until a fresh init scan.
74
+
75
+ ## Prepare an actual discovered workflow
76
+
77
+ After `init`, select a candidate from `.agenttwin/inventory.json` or the dashboard's New world view. Write `preparation.json` beside your application files:
20
78
 
21
79
  ```json
22
80
  {
23
- "version": 1,
24
- "world": "default",
25
- "twins": []
81
+ "schema": "agenttwin/preparation-v1",
82
+ "workflowId": "YOUR_DISCOVERED_WORKFLOW_ID",
83
+ "world": {
84
+ "schema": "agenttwin/world-v1",
85
+ "name": "notification",
86
+ "files": ["workflow.mjs"],
87
+ "command": ["node", "workflow.mjs"],
88
+ "timeoutSeconds": 20,
89
+ "services": [{"name":"slack","adapter":"slack","collections":[{"path":"/messages","seed":[]},{"path":"/channels","seed":[{"id":"C_TEST","name":"test"}]}]}],
90
+ "assertions": [{"service":"slack","path":"/messages","count":1}]
91
+ },
92
+ "mappings": [{"toolId":"YOUR_DISCOVERED_SLACK_TOOL_ID","service":"slack","contract":"slack","operations":["chat.postMessage"],"reviewed":true}]
26
93
  }
27
94
  ```
28
95
 
29
- Re-run with `--force` to overwrite an existing config.
96
+ Use your actual discovered IDs and include every operation recorded for the candidate. Configure code to use the generated `AGENTTWIN_SLACK_URL` and `AGENTTWIN_SLACK_TOKEN`; an SDK needs its base URL overridden. The runtime does not install dependencies or transpile source: include a built, self-contained Node entrypoint and every required application file. Preparation never executes your code.
30
97
 
31
98
  ```sh
32
- npx agenttwin --help
33
- npx agenttwin --version
99
+ npx agenttwin prepare --file preparation.json --out .agenttwin/prepared/notification
100
+ npx agenttwin run --file .agenttwin/prepared/notification/agenttwin.world.json
34
101
  ```
35
102
 
36
- ## Requirements
103
+ The output contains your unchanged source, a world spec, a SHA-256 manifest, and `agenttwin.bundle.json`. In Hosted runs, connect with an individual API token, choose that bundle, review the upload and execute. Jobs can be refreshed, cancelled and inspected. Tokens stay in page memory. Discovery imports remain in the browser; executing uploads the explicit bundle to the API.
104
+
105
+ Supported mapping contracts: bounded Slack operations, PostgreSQL, Redis and custom JSON collections (`GET /path` / `POST /path`). Preparation rejects missing/unreviewed mappings and unsupported vendor SDK operations. Discovery and mappings remain user-reviewed declarations, not proof that every operation or dependency in arbitrary source was discovered. Hosted execution checks the declared assertions.
106
+
107
+
108
+ ### Coding session and dashboard discovery
37
109
 
38
- Node.js 18 or newer.
110
+ Run `npx agenttwin init` inside your repository (Node.js 22+). Interactive init offers an OpenCode session when the CLI is installed; `npx agenttwin init --agent opencode` launches explicitly with your configured provider and its normal permission controls. Provider authentication and usage belong to your coding-agent account. Other coding agents can use `.agenttwin/AGENT-TASK.md`.
39
111
 
40
- ## Status
112
+ The session traces workflows across files, records intents and production failure hypotheses in `.agenttwin/WORKFLOWS.md`, and writes metadata to `.agenttwin/agent-discovery.json`. Static candidates retain their original evidence. Agent candidates remain unverified until the workflow is explicitly prepared and executed. Static discovery preserves distinct exported side-effect entrypoints, including repositories with 100 candidates; it does not prove that every business workflow has been found.
41
113
 
42
- `agenttwin init` is the only implemented command. Nothing here connects to real
43
- providers, requests credentials, or executes code. See the project repository for
44
- the product thesis and roadmap.
114
+ After reviewing discovery, configure `AGENTTWIN_TOKEN` using your individual account token (never paste it into an agent prompt) and run `npx agenttwin sync`. Optional `AGENTTWIN_API_URL` selects your API. The website loads account discovery after you connect in Settings, then refreshes while visible. Sync sends names, operations and relative entrypoint metadata; application source uploads happen separately through reviewed bundles. Avoid sensitive names or identifiers in discovery metadata.
45
115
 
46
- ## License
116
+ To execute a workflow, supply an executable Node entrypoint, reviewed supported dependency mappings, synthetic fixtures and expected observable outcomes. Run `npx agenttwin prepare --file preparation.json`, review the bundle, and run it through your AgentTwin API or E2B account. Browser/desktop automation and arbitrary vendor SDKs require additional runtimes/adapters. Every application execution is hosted; no local Docker is used.
47
117
 
48
- MIT
118
+ A run receipt's **Fix & retest** tab exports an evidence-based task for your coding agent. Edit the code in the original project, prepare a new bundle, execute in a fresh sandbox, and compare receipts. This is an interactive coding loop, not an unattended universal repair service.