@swarm-agent/sdk 0.1.47

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 (74) hide show
  1. package/APPLICATIONS.md +133 -0
  2. package/HEADLESS_UI.md +97 -0
  3. package/LICENSE +201 -0
  4. package/README.md +473 -0
  5. package/dist/app-results.d.ts +24 -0
  6. package/dist/app-results.js +167 -0
  7. package/dist/apps.d.ts +82 -0
  8. package/dist/apps.js +89 -0
  9. package/dist/auth.d.ts +45 -0
  10. package/dist/auth.js +89 -0
  11. package/dist/automations.d.ts +74 -0
  12. package/dist/automations.js +159 -0
  13. package/dist/client.d.ts +61 -0
  14. package/dist/client.js +103 -0
  15. package/dist/deliverables.d.ts +42 -0
  16. package/dist/deliverables.js +83 -0
  17. package/dist/deploy/dockerfile.d.ts +14 -0
  18. package/dist/deploy/dockerfile.js +14 -0
  19. package/dist/deploy/index.d.ts +67 -0
  20. package/dist/deploy/index.js +226 -0
  21. package/dist/deploy/manifest.d.ts +17 -0
  22. package/dist/deploy/manifest.js +220 -0
  23. package/dist/deploy/providers/gcp-cloud-run.d.ts +9 -0
  24. package/dist/deploy/providers/gcp-cloud-run.js +12 -0
  25. package/dist/deploy/providers/gcp-compute.d.ts +9 -0
  26. package/dist/deploy/providers/gcp-compute.js +12 -0
  27. package/dist/deploy/types.d.ts +211 -0
  28. package/dist/deploy/types.js +4 -0
  29. package/dist/deploy/worker-cloud-deployer.d.ts +33 -0
  30. package/dist/deploy/worker-cloud-deployer.js +14 -0
  31. package/dist/errors.d.ts +36 -0
  32. package/dist/errors.js +68 -0
  33. package/dist/index.d.ts +23 -0
  34. package/dist/index.js +20 -0
  35. package/dist/notifications.d.ts +28 -0
  36. package/dist/notifications.js +65 -0
  37. package/dist/projects.d.ts +147 -0
  38. package/dist/projects.js +513 -0
  39. package/dist/provider-auth.d.ts +160 -0
  40. package/dist/provider-auth.js +54 -0
  41. package/dist/realtime.d.ts +240 -0
  42. package/dist/realtime.js +312 -0
  43. package/dist/sessions.d.ts +60 -0
  44. package/dist/sessions.js +194 -0
  45. package/dist/settings.d.ts +85 -0
  46. package/dist/settings.js +26 -0
  47. package/dist/storage/adapters/memory.d.ts +13 -0
  48. package/dist/storage/adapters/memory.js +35 -0
  49. package/dist/storage/adapters/s3.d.ts +31 -0
  50. package/dist/storage/adapters/s3.js +171 -0
  51. package/dist/storage/client.d.ts +174 -0
  52. package/dist/storage/client.js +121 -0
  53. package/dist/storage/hub.d.ts +30 -0
  54. package/dist/storage/hub.js +372 -0
  55. package/dist/storage/index.d.ts +6 -0
  56. package/dist/storage/index.js +6 -0
  57. package/dist/storage/runner.d.ts +48 -0
  58. package/dist/storage/runner.js +233 -0
  59. package/dist/storage/types.d.ts +198 -0
  60. package/dist/storage/types.js +1 -0
  61. package/dist/system.d.ts +14 -0
  62. package/dist/system.js +52 -0
  63. package/dist/transport.d.ts +17 -0
  64. package/dist/transport.js +243 -0
  65. package/dist/types.d.ts +1137 -0
  66. package/dist/types.js +1 -0
  67. package/dist/usage.d.ts +106 -0
  68. package/dist/usage.js +82 -0
  69. package/dist/workers.d.ts +146 -0
  70. package/dist/workers.js +822 -0
  71. package/dist/workspaces.d.ts +81 -0
  72. package/dist/workspaces.js +58 -0
  73. package/examples/headless-session.ts +85 -0
  74. package/package.json +56 -0
@@ -0,0 +1,133 @@
1
+ # Application agents
2
+
3
+ `client.apps` stores named, account-and-user-owned application instructions/context.
4
+ It is **not** a mutable system-agent profile, worker, deployment or new executor.
5
+ Models, tools, permissions and worktree admission still use Swarm's canonical authorities.
6
+
7
+ Use an authenticated private BFF connection to the daemon local API (Unix socket
8
+ or authenticated loopback). These routes are deliberately **not** allowed on the
9
+ container SDK listener; do not expose the privileged socket or credentials to a browser.
10
+ The routes require `sessions:read` / `sessions:write`, respectively.
11
+
12
+ ## Minimal private-server quickstart
13
+
14
+ First construct `new SwarmClient()` in your BFF using its private environment/socket
15
+ transport (never in the browser). If Codex is not connected, after explicit user
16
+ consent call `client.auth.codex.start({method: 'device', active: false})`, display
17
+ only the allowlisted HTTPS verification URL/user code, and call
18
+ `client.auth.codex.status(login.session_id)` on user request until `status === 'success'`.
19
+ Bind the login ID to your authenticated app session. Manual sign-in uses
20
+ `start({method: 'manual', active: false})` then `complete(login.session_id, callback)`.
21
+ Completion saves credentials and **can initialize account model defaults**, even
22
+ with `active: false`; disclose this before starting. The current API has no cancel
23
+ endpoint: abandoning a device flow does not revoke authorization already granted.
24
+ These are user-driven calls, not startup hooks. App access tokens and provider
25
+ sign-in are separate. Use the hub's BFF as a redaction/correlation example.
26
+
27
+ With a saved workspace and configured account model:
28
+
29
+ ```ts
30
+ import { SwarmClient } from '@swarm-agent/sdk';
31
+ const client = new SwarmClient();
32
+ const agent = await client.apps.put('editor', {
33
+ name: 'Editor', instructions: 'Prepare drafts; do not publish.',
34
+ context: 'Use our approved style guide.', expected_revision: 0,
35
+ });
36
+ const conversation = await client.apps.createConversation(agent.id, {
37
+ workspace_id: savedWorkspaceId, revision: agent.revision,
38
+ client_request_id: 'conversation-opening-1', title: 'Draft review',
39
+ });
40
+ await client.apps.send(agent.id, conversation.id, {
41
+ content: 'Prepare a launch announcement.', client_request_id: 'event-1',
42
+ });
43
+ // Persist these IDs in the application; reopen after reload or daemon restart.
44
+ const result = await client.apps.conversation(agent.id, conversation.id);
45
+ ```
46
+
47
+ `PUT /v3/application-agents/{id}` creates at expected revision zero or updates at
48
+ an exact revision; an identical immediately retried write returns the same record.
49
+ Stale/different writes return 409. `GET` returns latest context. Each conversation
50
+ pins an immutable revision at creation. Updates affect **new** conversations only;
51
+ they never silently rewrite an existing conversation's instructions. Use the same
52
+ request ID and revision when retrying creation or delivering the same event.
53
+ Instructions reach the V3 provider instruction boundary, not synthetic chat messages.
54
+ Conversation/message/event routes verify both principal and server-stored binding.
55
+ `apps.list({limit, cursor})` discovers persisted agents (limit 1–100). Use the returned
56
+ `next_cursor` unchanged. `apps.conversations(id)` returns a bounded recent view,
57
+ explicitly reporting when its 1,000-session scan limit is reached; retained IDs
58
+ always reopen directly. There is no delete API in this initial contract.
59
+
60
+ ## Task-oriented applications remain independent
61
+
62
+ No conversation UX is required for the existing project task or worker APIs:
63
+
64
+ ```ts
65
+ const queued = await client.projects.createTask(projectId, {
66
+ agent: 'swarm', title: 'Prepare release notes', description: 'Summarize approved changes.',
67
+ });
68
+ // Use the returned task ID with the existing approval/reopen lifecycle.
69
+ const result = await client.projects.getTask(projectId, taskId);
70
+ const worker = await client.workers.get(workerId);
71
+ ```
72
+
73
+ Optionally include `project_id` and `worker_ids` in `apps.put`. The server validates
74
+ account ownership and resource-read scopes before persisting these links. These
75
+ links are navigation/execution targets, not context synchronization:
76
+
77
+ ```ts
78
+ await client.apps.createTask(agent.id, { id: durableJobId, agent: 'swarm', title: 'Draft', description: brief });
79
+ const tasks = await client.apps.tasks(agent.id);
80
+ const worker = await client.apps.worker(agent.id, linkedWorkerId);
81
+ const runs = await client.apps.runs(agent.id, linkedWorkerId);
82
+ ```
83
+
84
+ Task creation requires an explicit `agent` or `intent`; `agent: 'swarm'` selects
85
+ ordinary general work, not a model/provider override. The linked project must have
86
+ an authorized repository workspace resolvable by canonical source admission.
87
+ Reuse the same durable task ID and payload on retry. Creation does not request
88
+ auto-approval; retain the existing approval lifecycle.
89
+
90
+ Projects, tasks and workers retain their own server-side context, revision,
91
+ trigger and result contracts. Task requests go through canonical project admission;
92
+ linked configuration uses `apps.configureAutomation(id, workerId, revision, input, automationId?)`;
93
+ `apps.trigger(id, {worker_id, automation_id, payload, idempotency_key})` preserves delivery identity.
94
+ Unlinked worker IDs are rejected. Canonical worker scopes, revisions and approval gates remain enforced;
95
+ activation, deployment, enable/disable and token minting are deliberately not forwarded.
96
+ The editable `examples/agent-hub` UI demonstrates these calls.
97
+ Task execution may have internal durable sessions without requiring chat in your UX.
98
+ Worker deployment/automation management is an Orchestrator operation. These snippets
99
+ are API usage examples, not a claim of a live deployed or cloud-verified workflow.
100
+
101
+ ## Automatic results without a chat UI
102
+
103
+ <copy>
104
+ const results = client.apps.watchResults(agent.id, {
105
+ onChange: ({ tasks, workers }) => renderResults(tasks, workers),
106
+ onError: () => showReconnectButton(),
107
+ });
108
+ await results.ready;
109
+ // On logout, navigation or component disposal:
110
+ results.dispose();
111
+ await results.done;
112
+
113
+ const chat = await client.apps.watchConversation(agent.id, conversation.id, {
114
+ onChange: ({ messages, live }) => renderConversation(messages, live),
115
+ });
116
+ </copy>
117
+
118
+ Watchers use the existing authenticated V3 socket, opaque snapshot resume cursors,
119
+ authorized resource reads and bounded reconnects. No polling or new execution state
120
+ is introduced. The resource watcher uses the daemon's account-scoped, content-free
121
+ worker invalidation signals; project invalidations are filtered by the linked ID.
122
+ It returns bounded task/run lists, not an unlimited event ledger. Disconnects re-read
123
+ durable state, not transient event payloads. Browser apps should stream these selected
124
+ results through their authenticated BFF; never send daemon credentials to the browser.
125
+
126
+ Resource-only resume currently has no explicit acceptance/replay-done frame.
127
+ `watchResults.ready` waits for a post-hello resource/watermark/keepalive and a fresh
128
+ authorized snapshot (idle connections can take one 15-second keepalive interval).
129
+ This is a liveness fence, not an atomic snapshot of all resources. Read-time
130
+ invalidations coalesce into another read; reconnect bootstraps again.
131
+ Worker signals currently omit worker IDs, so **every account worker invalidation
132
+ requires refreshing linked workers**; unrelated worker events cannot safely be
133
+ filtered client-side. Per-worker invalidation needs a backend protocol change.
package/HEADLESS_UI.md ADDED
@@ -0,0 +1,97 @@
1
+ # Build a real headless UI with the SDK
2
+
3
+ ## Trust boundary
4
+
5
+ Run the administrative Node SDK in your backend-for-frontend **inside the same container as swarmd**, using its configured private Unix socket. Do not mount/export that socket, put daemon credentials in browser code, or forward arbitrary browser-selected daemon paths. Authenticate your app's users, check Origin/CSRF, and allowlist app operations. Never log credential request bodies. The separate `--container-sdk-port` listener remains session-only: it cannot onboard providers, change settings, or create workspaces.
6
+
7
+ Node 22+ is required. `ws` supplies Unix-socket WebSocket upgrades; HTTP and WebSocket requests use the same SDK credentials/headers. Browser use requires a same-origin authenticated app proxy, no SDK bearer token; otherwise forward watcher updates from your BFF using your app's authenticated SSE/WebSocket transport.
8
+
9
+ ## Discover, authenticate, configure
10
+
11
+ <copy>
12
+ import { SwarmClient } from '@swarm-agent/sdk';
13
+ const swarm = new SwarmClient({ socketPath: process.env.SWARM_SOCKET_PATH });
14
+ const onboarding = await swarm.onboarding.get();
15
+ const providers = await swarm.settings.providers(); // readiness and supported auth_methods
16
+ const credentials = await swarm.auth.credentials.list(); // redacted status only
17
+ </copy>
18
+
19
+ Your app must supply its configured socket path and authenticated local identity. This is not a recipe to import host credentials. Complete the daemon's identity/onboarding requirements using `onboarding.update({ username, swarm_name })` when needed.
20
+
21
+ For an API key collected through your app UI, pass the user-selected provider and its advertised credential type. The first-provider endpoint requires zero existing credentials/agents; use the ordinary save endpoint afterward. Errors are not silently retried on a different route.
22
+
23
+ <copy>
24
+ await swarm.auth.credentials.save({
25
+ provider: selectedProvider, type: selectedCredentialType,
26
+ api_key: submittedKey, label: 'Headless app', active: true,
27
+ });
28
+ const catalog = await swarm.settings.models(selectedProvider);
29
+ const settings = await swarm.settings.agentModels();
30
+ // Display catalog.records and settings.agent_model_settings. Never invent a model fallback.
31
+ // Optional explicit user selection:
32
+ await swarm.settings.setSwarmModel('action', selectedAssignment);
33
+ </copy>
34
+
35
+ `auth.credentials` also exposes `verify(provider, id)`, `activate(provider, id)`, and `delete(provider, id)`. Verification may call a real provider. First-run OpenAI credentials may be stored active but unverified; inspect `connection` and `auto_defaults.error` rather than treating storage as successful inference.
36
+
37
+ ### Codex sign-in
38
+
39
+ <copy>
40
+ const login = await swarm.auth.codex.start({ method: 'device', active: true });
41
+ // Display login.verification_url and login.user_code; never display access tokens.
42
+ // On explicit refresh, or a bounded UI login-status loop stopped at expiry/unmount:
43
+ const status = await swarm.auth.codex.status(login.session_id);
44
+ // status.status: waiting / authorizing / success / error
45
+ </copy>
46
+
47
+ Device login completes asynchronously in the daemon and is the preferred container flow. `manual` returns `auth_url`; submit the user's callback input with `auth.codex.complete(login.session_id, callbackInput)`. `browser` also returns `auth_url`, but its callback listener runs where the daemon runs, not automatically in the host browser's network namespace. Do not claim browser callback reachability without configuring and testing it. Device sessions reject `complete`. Login-status polling is separate from session realtime; chat must not poll.
48
+
49
+ ## Create a workspace and durable session
50
+
51
+ <copy>
52
+ const folder = await swarm.workspaces.createFolder(configuredWorkspaceParent, 'my-app');
53
+ const repository = await swarm.workspaces.inspectRepository(folder.path);
54
+ if (repository.can_setup) {
55
+ // Explicit user-approved Git initialization; expected path guards identity changes.
56
+ await swarm.workspaces.setupRepository(folder.path, repository.path);
57
+ }
58
+ const workspace = await swarm.workspaces.add({ path: folder.path, make_current: false });
59
+ const session = await swarm.sessions.create({
60
+ workspace_path: workspace.workspace_path, title: 'My app chat', mode: 'auto',
61
+ });
62
+ </copy>
63
+
64
+ Do not automatically commit existing content. `reviewRepository(path)` returns selectable paths and a review digest; `baselineRepository(...)` requires that digest, exact selected paths and explicit confirmations. `add` may return a repository prerequisite/content-review conflict. Surface it, do not silently set `confirm_committed_only`. Folder creation, Git preparation, registration and session creation are separate operations; failures can leave a created folder without a registered workspace.
65
+
66
+ ## Stream without reverse engineering
67
+
68
+ <copy>
69
+ const abort = new AbortController();
70
+ const watch = swarm.realtime.watchSession(session.id, {
71
+ signal: abort.signal,
72
+ onChange(state) {
73
+ // Replace the displayed snapshot. Key durable messages by id.
74
+ // Render state.live separately by [runId, streamId]; it contains full text,
75
+ // not append-only deltas. Committed streams disappear from this overlay.
76
+ sendToAuthenticatedAppClient(state);
77
+ },
78
+ onError(error) { reportAppError(error.message); },
79
+ });
80
+ await watch.ready; // initial snapshot and scoped replay subscription established
81
+ // Keep the same client_request_id when retrying this submission.
82
+ await swarm.sessions.sendMessage(session.id, { content: userText, client_request_id });
83
+ await watch.done; // rejects on terminal transport/protocol/auth errors
84
+ // On app disconnect: watch.dispose() or abort.abort().
85
+ </copy>
86
+
87
+ The watcher hydrates one session (including its session view), waits for `hello` (`v3.realtime`, version 1), and resumes from the **snapshot handoff cursor**, not the newer hello head. The server replays to the subscription before delivering live updates. It advertises `live_patch_v1` only when the server offers it. UTF-8 byte offsets and sequence ranges deduplicate live text; durable checkpoints and committed messages remain authoritative. Foreign-session frames never update the view.
88
+
89
+ Durable events trigger coalesced `/v3/sync/hydrate` reads, not interval polling. Disconnects, cursor errors and slow consumers start fresh scoped hydration/replay with bounded exponential backoff (six retries, 250ms to 8s). Authentication/protocol errors terminate. No cursor is parsed, numerically compared, or persisted across watches/principals. `dispose` cancels HTTP, closes WebSocket, and ends `done`; a disposed-before-ready watcher rejects `ready`.
90
+
91
+ ### Bounded view and raw access
92
+
93
+ The high-level view is a **200-message / 200-event tail**, not the complete transcript. Inspect `snapshot.pagination`, `omissions`, history manifests and session views before claiming complete history. A mid-stream reconnect whose retained event tail lacks the stream prefix may show no partial draft until a durable complete message arrives; it never guesses missing text. A live offset gap pauses that stream's speculative patches and relies on durable repair. Live overlays are bounded to 64 streams / 4 MiB per stream. Tool, plan, permission and other resources stay in the canonical raw snapshot; the SDK does not invent a second plan authority.
94
+
95
+ `realtime.bootstrap(request)`, `hydrate(request)` and `replay({...request, endpoint_cursor, limit})` expose typed canonical V3 envelopes for advanced consumers. Keep surface, selector and resources identical when using `/v3/sync/stream` cursors. `realtime.socket(path)` exposes transport only; raw consumers own reducer/replay correctness. The convenience watcher uses fresh durable repair on reconnect rather than retaining a possibly stale speculative cache.
96
+
97
+ No live daemon/provider or container validation is claimed by this guide. Unit fixtures prove wire/reducer behavior only; the deploying app must verify onboarding, real inference, streamed text, restart recovery and container isolation against its candidate.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Swarm contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.