@msg91comm/m91 0.0.0-stage → 1.2.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +21 -0
  3. package/README.md +647 -2
  4. package/dist/src/client.d.ts +165 -0
  5. package/dist/src/client.d.ts.map +1 -0
  6. package/dist/src/client.js +221 -0
  7. package/dist/src/client.js.map +1 -0
  8. package/dist/src/exceptions.d.ts +114 -0
  9. package/dist/src/exceptions.d.ts.map +1 -0
  10. package/dist/src/exceptions.js +199 -0
  11. package/dist/src/exceptions.js.map +1 -0
  12. package/dist/src/http.d.ts +71 -0
  13. package/dist/src/http.d.ts.map +1 -0
  14. package/dist/src/http.js +150 -0
  15. package/dist/src/http.js.map +1 -0
  16. package/dist/src/index.d.ts +49 -0
  17. package/dist/src/index.d.ts.map +1 -0
  18. package/dist/src/index.js +45 -0
  19. package/dist/src/index.js.map +1 -0
  20. package/dist/src/integrations/claude-agent-sdk.d.ts +63 -0
  21. package/dist/src/integrations/claude-agent-sdk.d.ts.map +1 -0
  22. package/dist/src/integrations/claude-agent-sdk.js +109 -0
  23. package/dist/src/integrations/claude-agent-sdk.js.map +1 -0
  24. package/dist/src/integrations/google-adk.d.ts +47 -0
  25. package/dist/src/integrations/google-adk.d.ts.map +1 -0
  26. package/dist/src/integrations/google-adk.js +84 -0
  27. package/dist/src/integrations/google-adk.js.map +1 -0
  28. package/dist/src/integrations/index.d.ts +26 -0
  29. package/dist/src/integrations/index.d.ts.map +1 -0
  30. package/dist/src/integrations/index.js +25 -0
  31. package/dist/src/integrations/index.js.map +1 -0
  32. package/dist/src/integrations/langchain.d.ts +94 -0
  33. package/dist/src/integrations/langchain.d.ts.map +1 -0
  34. package/dist/src/integrations/langchain.js +129 -0
  35. package/dist/src/integrations/langchain.js.map +1 -0
  36. package/dist/src/integrations/langgraph.d.ts +79 -0
  37. package/dist/src/integrations/langgraph.d.ts.map +1 -0
  38. package/dist/src/integrations/langgraph.js +114 -0
  39. package/dist/src/integrations/langgraph.js.map +1 -0
  40. package/dist/src/integrations/mastra.d.ts +75 -0
  41. package/dist/src/integrations/mastra.d.ts.map +1 -0
  42. package/dist/src/integrations/mastra.js +109 -0
  43. package/dist/src/integrations/mastra.js.map +1 -0
  44. package/dist/src/integrations/openai-agents.d.ts +61 -0
  45. package/dist/src/integrations/openai-agents.d.ts.map +1 -0
  46. package/dist/src/integrations/openai-agents.js +127 -0
  47. package/dist/src/integrations/openai-agents.js.map +1 -0
  48. package/dist/src/integrations/specs.d.ts +173 -0
  49. package/dist/src/integrations/specs.d.ts.map +1 -0
  50. package/dist/src/integrations/specs.js +217 -0
  51. package/dist/src/integrations/specs.js.map +1 -0
  52. package/dist/src/integrations/vercel-ai.d.ts +74 -0
  53. package/dist/src/integrations/vercel-ai.d.ts.map +1 -0
  54. package/dist/src/integrations/vercel-ai.js +102 -0
  55. package/dist/src/integrations/vercel-ai.js.map +1 -0
  56. package/dist/src/integrations/zod-shapes.d.ts +19 -0
  57. package/dist/src/integrations/zod-shapes.d.ts.map +1 -0
  58. package/dist/src/integrations/zod-shapes.js +44 -0
  59. package/dist/src/integrations/zod-shapes.js.map +1 -0
  60. package/dist/src/models.d.ts +274 -0
  61. package/dist/src/models.d.ts.map +1 -0
  62. package/dist/src/models.js +383 -0
  63. package/dist/src/models.js.map +1 -0
  64. package/dist/src/platform.d.ts +176 -0
  65. package/dist/src/platform.d.ts.map +1 -0
  66. package/dist/src/platform.js +286 -0
  67. package/dist/src/platform.js.map +1 -0
  68. package/dist/src/url-builder.d.ts +65 -0
  69. package/dist/src/url-builder.d.ts.map +1 -0
  70. package/dist/src/url-builder.js +167 -0
  71. package/dist/src/url-builder.js.map +1 -0
  72. package/examples/approval-gate.ts +35 -0
  73. package/examples/basic-alert.ts +53 -0
  74. package/examples/claude-agent-sdk.ts +23 -0
  75. package/examples/deep-agents.ts +31 -0
  76. package/examples/google-adk.ts +39 -0
  77. package/examples/langchain-agent.ts +65 -0
  78. package/examples/langgraph-hitl.ts +70 -0
  79. package/examples/mastra.ts +41 -0
  80. package/examples/openai-agents.ts +33 -0
  81. package/examples/vercel-ai-agent.ts +34 -0
  82. package/examples/webhook-urls.ts +44 -0
  83. package/package.json +135 -4
  84. package/src/client.ts +324 -0
  85. package/src/exceptions.ts +229 -0
  86. package/src/http.ts +174 -0
  87. package/src/index.ts +91 -0
  88. package/src/integrations/claude-agent-sdk.ts +158 -0
  89. package/src/integrations/google-adk.ts +122 -0
  90. package/src/integrations/index.ts +27 -0
  91. package/src/integrations/langchain.ts +207 -0
  92. package/src/integrations/langgraph.ts +142 -0
  93. package/src/integrations/mastra.ts +178 -0
  94. package/src/integrations/openai-agents.ts +173 -0
  95. package/src/integrations/specs.ts +328 -0
  96. package/src/integrations/vercel-ai.ts +151 -0
  97. package/src/integrations/zod-shapes.ts +55 -0
  98. package/src/models.ts +660 -0
  99. package/src/platform.ts +343 -0
  100. package/src/url-builder.ts +225 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,94 @@
1
+ # Changelog
2
+
3
+ ## 1.2.0
4
+
5
+ ### Added
6
+ - **OpenAI Agents SDK** (`@msg91comm/m91/integrations/openai-agents`): `runWithM91Approvals` answers every `needsApproval` interruption on a phone and resumes the run; `approveInterruptionsWithM91` for your own loop; `createM91Tools`.
7
+ - **Claude Agent SDK** (`@msg91comm/m91/integrations/claude-agent-sdk`): `createM91CanUseTool` (a `canUseTool` callback), `createM91PreToolUseHook` (gates in every permission mode), and `createM91McpServer` (the two tools as an in-process MCP server).
8
+ - **Google ADK for TypeScript** (`@msg91comm/m91/integrations/google-adk`): `createM91BeforeToolCallback` gates named tools; `createM91Tools` as `FunctionTool`s.
9
+ - **Mastra** (`@msg91comm/m91/integrations/mastra`): `generateWithM91Approvals` answers `requireApproval` suspensions; `createM91Tools`.
10
+ - **Vercel AI SDK**: `createM91ToolApproval`, a `toolApproval` function that rings a phone before the tools you name run.
11
+ - **LangChain `humanInTheLoopMiddleware` and Deep Agents** (`@msg91comm/m91/integrations/langchain`): `invokeWithM91Approvals` answers each `interruptOn` pause on a phone and resumes with `Command({ resume: { decisions } })`; `resolveHITLWithM91` builds the decisions for your own loop.
12
+ - `decideToolCall`, `GateOptions`: the shared fail-closed gate every adapter above uses.
13
+
14
+ ### Fixed
15
+ - Vercel AI SDK tool factories return `Tool` / `ToolSet`, and LangChain's return `DynamicStructuredTool`, instead of `unknown`, so they type-check in `generateText({ tools })` and `createAgent({ tools })`. Runtime behaviour is unchanged.
16
+ - The `ai` peer range is `>=5.0.0`, matching the `inputSchema` tool format.
17
+ - Docs and docstrings use the published package name (`@msg91comm/m91`) and current APIs (`createAgent`, `isStepCount`).
18
+
19
+ ## Fixed
20
+ - `@msg91comm/m91/integrations/vercel-ai`: `createM91ApprovalTool`, `createM91AlertTool` and `createM91Tools` are now typed as the AI SDK's `Tool` / `ToolSet` instead of `unknown`, so they type-check inside `generateText({ tools })`. Runtime behaviour is unchanged.
21
+ - The `ai` peer dependency range is now `>=5.0.0`, matching the `inputSchema` tool format these factories use.
22
+
23
+ ## 1.1.1
24
+
25
+ Metadata only — no code change.
26
+
27
+ `homepage` pointed at `https://m91.msg91.com`, which does not resolve: that
28
+ host is the static site, and every backend route lives on `m91-api.msg91.com`.
29
+ npm renders `homepage` as a link on the package page and freezes it per
30
+ version, so 1.1.0's link is dead for the life of that version. It now points at
31
+ the documentation.
32
+
33
+ The package also went out as `@msg91comm/m91` while the repository still said
34
+ `"name": "m91"`, so the next publish would have gone to a different package.
35
+ The repository now matches what is published.
36
+
37
+
38
+ ## 1.1.0
39
+
40
+ Three gaps where the server had grown a field and the SDK had not, so the only
41
+ route to a value you had explicitly asked for was the raw body.
42
+
43
+ **Nothing breaks.** `AlertDetail.responses` holds typed objects now, and they
44
+ still answer to `r["label"]` and `r.get("note")` — the spelling callers already
45
+ use — so upgrading changes nothing you have written. (Python; in Node they were
46
+ `unknown[]`, which required a cast either way.)
47
+
48
+ ### Added
49
+
50
+ - `send({ attachments: [...] })` — https links to files the alert is about. URLs,
51
+ never bytes, because every automation a send link is pasted into has a URL
52
+ field and little else. Validated locally so a typo costs no round trip.
53
+ - `send({ callbackUrl: ... })` — where the outcome is POSTed when somebody answers.
54
+ - `Response.note` and `Response.attachments`, the two things a sender can
55
+ require before an option may be chosen.
56
+ - `AlertDetail.attachments` and `AlertDetail.pending`.
57
+ - `Attachment` and `Response` types.
58
+ - `M91Platform.listChannels()` — the
59
+ missing half of the non-idempotent `create_channel`. A platform that lost the
60
+ response to a create had an orphaned channel and no way to find it.
61
+
62
+
63
+ ## 1.0.0
64
+
65
+ First release.
66
+
67
+ - `M91Client` — verify, send, getAlert, waitForDecision, close, requestApproval,
68
+ against a channel send link.
69
+ - `M91Platform` — verify the key, invite and alert one person by phone number,
70
+ and provision team channels, with an API key.
71
+ - `M91URLBuilder` — the GET form, for anything whose only field is "URL to call".
72
+ - Integrations: LangChain, LangGraph and the Vercel AI SDK.
73
+
74
+ Zero runtime dependencies: native `fetch`, Node 18+. Every framework adapter
75
+ imports its framework lazily, so installing this package pulls in none of them.
76
+
77
+ Four behaviours worth calling out, because they are the ones that differ from
78
+ what a hand-rolled wrapper around `fetch` usually does:
79
+
80
+ - **A send that reaches nobody throws `M91DeliveryError`.** `delivered` counts
81
+ phones actually sent to, not the size of the roster, so a channel whose device
82
+ tokens are all stale answers 201 and wakes nobody. This applies to
83
+ `alertPerson` as well as `send`, and matters more there: a direct alert has a
84
+ roster of one. Pass `{ throwOnZeroDelivery: false }` to opt out.
85
+ - **`close()` treats 404 and 403 as success.** Nothing left to close is the
86
+ state the caller asked for.
87
+ - **`waitForDecision()` reads `decision` only.** A PERSONAL response ("Seen")
88
+ never ends the wait, because "Seen" must never read as "Approved".
89
+ - **`verify()` on both clients tests a credential without waking anybody.**
90
+ `M91Client.verify()` pings the send link; `M91Platform.verify()` calls
91
+ `GET /api/v1/me` and names the key and its owner.
92
+ - **The send token is redacted from every string the SDK produces** — `toString`,
93
+ error messages and tool results — including text written by the runtime, which
94
+ can name the URL a request failed on.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MSG91
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.