@trv-hq/trv-paystack-utils 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,10 @@
1
- import crypto from "crypto";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isPayloadValid = isPayloadValid;
7
+ const crypto_1 = __importDefault(require("crypto"));
2
8
  const TOLERANCE_SECONDS = 300;
3
9
  // Returns the key id (kid) of the signature that matched, or null.
4
10
  function verifyPaystackSignature(rawBody, header, secrets, now = Math.floor(Date.now() / 1000)) {
@@ -28,21 +34,21 @@ function verifyPaystackSignature(rawBody, header, secrets, now = Math.floor(Date
28
34
  if (Math.abs(now - t) > TOLERANCE_SECONDS)
29
35
  return null;
30
36
  for (const secret of secrets) {
31
- const expected = crypto.createHmac('sha512', secret).update(t + '.').update(rawBody).digest();
37
+ const expected = crypto_1.default.createHmac('sha512', secret).update(t + '.').update(rawBody).digest();
32
38
  for (const { kid, hex } of entries) {
33
39
  if (!/^[0-9a-f]{128}$/.test(hex))
34
40
  continue;
35
- if (crypto.timingSafeEqual(expected, Buffer.from(hex, 'hex')))
41
+ if (crypto_1.default.timingSafeEqual(expected, Buffer.from(hex, 'hex')))
36
42
  return kid;
37
43
  }
38
44
  }
39
45
  return null;
40
46
  }
41
47
  function verifyXPaystackSignature(rawBody, signature = '', secret) {
42
- const hash = crypto.createHmac('sha512', secret).update(rawBody).digest();
43
- return !(!/^[0-9a-f]{128}$/.test(signature) || !crypto.timingSafeEqual(hash, Buffer.from(signature, 'hex')));
48
+ const hash = crypto_1.default.createHmac('sha512', secret).update(rawBody).digest();
49
+ return !(!/^[0-9a-f]{128}$/.test(signature) || !crypto_1.default.timingSafeEqual(hash, Buffer.from(signature, 'hex')));
44
50
  }
45
- export async function isPayloadValid(request, rawBody, secret) {
51
+ async function isPayloadValid(request, rawBody, secret) {
46
52
  const paystackSignature = request.headers.get('paystack-signature');
47
53
  const xpaystackSignature = request.headers.get('x-paystack-signature');
48
54
  if (paystackSignature) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,mEAAmE;AACnE,SAAS,uBAAuB,CAAC,OAA4B,EAAE,MAAqB,EAAE,OAAiB,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IACxI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEzE,IAAI,CAAC,GAAG,IAAI,CAAC;IACb,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,CAAC;YAAE,SAAS;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YACvD,CAAC,GAAG,MAAM,CAAC,KAAK,CA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AE,iBAAiB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAC1E,CAAC;SAAM,IAAI,kBAAkB,EAAE,CAAC;QAC5B,OAAO,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAA;IACxE,CAAC;SAAM,CAAC;QACJ,OAAO,KAAK,CAAA;IAChB,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trv-hq/trv-paystack-utils",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "paystack helpers",
5
5
  "keywords": [
6
6
  "paystack",
@@ -16,7 +16,6 @@
16
16
  },
17
17
  "license": "ISC",
18
18
  "author": "Uchenna Nwaorgu",
19
- "type": "module",
20
19
  "main": "dist/index.js",
21
20
  "types": "./dist/index.d.ts",
22
21
  "scripts": {
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: run-workflow
3
+ description: 'How to write and run a dynamic workflow script with the `run_workflow` tool: a Python script that orchestrates many agents with `agent`, `parallel`, `pipeline`, and `phase`. Use when a task splits into many independent or staged pieces of agent work (fan out over files, modules, bugs, or review angles, then aggregate), or when the user asks for a workflow. Don''t use for a single delegated task (use a subagent) or for legacy workflow files (see migrate-workflows).'
4
+ metadata:
5
+ namespace: system
6
+ ---
7
+ # Dynamic workflows with `run_workflow`
8
+
9
+ A workflow is a short Python script that the `run_workflow` tool executes. The
10
+ script decides which agents to start, in what order, and what to do with their
11
+ results. Use it instead of many manual subagent calls when the orchestration
12
+ itself is code: loops over a list, fan-out then aggregate, or staged pipelines.
13
+
14
+ ## Steps
15
+
16
+ 1. Pass the script inline as `Script`, or write it to a file (for example in
17
+ the conversation scratch directory) and pass its absolute path as
18
+ `ScriptPath`. Set exactly one of them; a file is easier to fix and rerun.
19
+ 2. Call `run_workflow(Script="...", Description="...")` or
20
+ `run_workflow(ScriptPath="/abs/path/workflow.py", Description="...")`.
21
+ `Description` is a one-line goal shown in the UI.
22
+ The workflow runs in the background, and you are notified when it ends.
23
+ For a quick script, such as a `call_tool` fan-out, set
24
+ `WaitMsBeforeAsync` (up to 10000) to get the result in the same turn if it
25
+ finishes in time.
26
+ To pass inputs, set `Args` to a JSON object; the script reads it as the
27
+ `args` dict. When `ScriptPath` is a saved workflow's entry script, `Args`
28
+ is validated against the args schema in its `workflow.json`.
29
+ 3. Read the tool result: it contains the `log()` output (`Logs:`) and what the
30
+ script printed (`Output:`). Each agent is also linked from the workflow
31
+ step, so the user can open its conversation.
32
+ 4. If the tool returns an error, fix the script at the reported line and run
33
+ it again.
34
+
35
+ ## Script rules
36
+
37
+ The script runs in its own `python3` process, which needs Python 3.8 or later
38
+ on `PATH`:
39
+
40
+ - `await` works at the top level, and you can define `async def` helpers.
41
+ - Installed library workflows are importable by name (`import <library>` or
42
+ `from <library> import <name>`); library modules see the same primitives as
43
+ the script.
44
+ - What the script prints (`print()`, `stderr`, child-process output, and the
45
+ `repr` of a trailing expression) is returned in the tool result's `Output:`
46
+ section (and appended to the error when the workflow fails).
47
+ - An uncaught exception stops the workflow and reports the script line.
48
+ - `CONVERSATION_ID` and `STEP_INDEX` identify the `run_workflow` step.
49
+ `WORKSPACES` is a tuple of the workspace directories, primary first (empty
50
+ if there are none).
51
+ - The working directory is `Cwd` if given, else `WORKSPACES[0]`, so relative
52
+ paths resolve against it. Local modules are not importable.
53
+
54
+ ## Primitives
55
+
56
+ | Primitive | Behavior |
57
+ | --- | --- |
58
+ | `log(*args)` | Adds a line to the workflow output and the UI. |
59
+ | `phase(name)` | Starts a named phase; later logs and agents group under it. |
60
+ | `agent(prompt=None, schema=None, role=None, type_name="self", workspace="inherit", model=None)` | Defines an agent; nothing runs yet. `await agent(prompt, schema)` runs it once and returns its result. `a = agent(...)` then `await a(prompt, schema)` runs one turn in a conversation kept across calls. |
61
+ | `parallel(items, fn)` | Promise that calls `fn(item)` for each item and awaits all results concurrently; results are in item order. If one fails, the rest are cancelled. |
62
+ | `pipeline(items, fn)` | Promise that calls and awaits `fn(item)` one item at a time; results are in item order. |
63
+ | `trajectory(last=None, types=None, tools=None, min_index=None, max_index=None)` | `await trajectory()` returns steps before this `run_workflow` call started, oldest first. `min_index` and `max_index` bound `step.index` (inclusive); `types` and `tools` filter by step type or tool name; `last` keeps the last N matching steps. |
64
+
65
+ Arguments:
66
+
67
+ - `type_name`: the agent type to run. `"self"` uses the current agent's
68
+ configuration; any available custom agent name also works.
69
+ - `workspace`: `"inherit"` (the current workspace), `"branch"` (a new isolated
70
+ clone, for agents that edit code in parallel), or `"share"` (a new workspace
71
+ that shares the underlying repository). Other values are errors.
72
+ - `schema` (required): a JSON schema (dict or string) for the agent's result.
73
+ The agent returns the result by calling its `finish` tool, which checks it
74
+ against the schema, and `await agent(...)` returns the parsed value. An
75
+ agent that ends without calling `finish` fails the workflow. Use
76
+ `{"type": "string"}` for a free-form answer.
77
+ - `role`: an optional short title for the agent's card, such as
78
+ `"Security reviewer"`.
79
+ - `model`: the agent's model tier: `"inherit"` (default, your model),
80
+ `"flash_lite"`, `"flash"`, or `"pro"`. Use a lighter tier for simple,
81
+ high-fan-out work.
82
+ - `fn`: usually a `lambda` that returns `agent(...)`, or an `async def`
83
+ helper that awaits several agents. It must return something awaitable:
84
+ an `agent()` or a call on one, a nested `parallel()` / `pipeline()`, or
85
+ an `async def` call. Build per-item prompts and roles with f-strings.
86
+
87
+ Awaiting the same agent twice runs it once and returns the same result. An
88
+ `agent()` that is never awaited or called never runs, so always `await` it, or
89
+ pass it to `parallel` / `pipeline` and await that.
90
+
91
+ The workflow step shows one card per agent, in the order agents start, titled
92
+ with its `role`, or else the first line of its prompt, so set a role or start
93
+ each prompt with a short line that names the job.
94
+
95
+ ## Agents that keep their context
96
+
97
+ When one agent should do several related turns, such as a reviewer that checks
98
+ the fixes for the bugs it found, call it instead of awaiting it. Each
99
+ `a(prompt, schema)` is lazy like an awaited `agent()` and returns that turn's
100
+ `finish` result; the agent's own `prompt`, if any, is its standing instructions
101
+ and leads the first turn. `schema` on a call defaults to the agent's. Turns on
102
+ one agent run one at a time, in the order they were started. A failed turn
103
+ raises, but the agent stays usable. An agent is either awaited or called, not
104
+ both. `del a` ends the agent, unless something else, such as a lambda, still
105
+ references it; every agent ends when the workflow ends.
106
+
107
+ ```python
108
+ reviewer = agent("You review Go code for correctness.", role="Reviewer")
109
+ bugs = await reviewer("List the bugs in foo.go.", {"type": "array", "items": {"type": "string"}})
110
+ fixes = await parallel(bugs, lambda b: agent(f"Fix: {b}", {"type": "string"}))
111
+ ok = await reviewer(f"Fixes made: {fixes}. Are all your bugs fixed?", {"type": "boolean"})
112
+ del reviewer
113
+ ```
114
+
115
+ ## Calling tools from the script
116
+
117
+ Where the `run_workflow` tool description lists tools for `call_tool`, the
118
+ script can call them directly:
119
+
120
+ - `call_tool(name, **args)` returns a promise like `agent()` does. Awaiting it
121
+ runs the tool with the arguments you would pass to it directly and returns
122
+ the tool's output as a `str`.
123
+ - It raises `ToolError` (with `.tool` and `.message`) if the tool fails or
124
+ the call is denied. `.denied` is `True` when a pre-tool hook or the
125
+ permission check rejected the call before the tool ran, so a script can
126
+ skip denied calls and still fail on real errors.
127
+ - The user cannot be asked anything from a workflow: a call that needs user
128
+ approval that has not already been granted is denied.
129
+ - Tool outputs are not shown to you unless the script logs or prints them.
130
+
131
+ ## Reading earlier conversation steps
132
+
133
+ Pass inputs you already have in `Args` (or inline in the script). Use
134
+ `await trajectory(...)` when the script needs to inspect steps from earlier in
135
+ this conversation—such as mining a failed `run_command` output without
136
+ rerunning it—and pass only the relevant slice into child `agent()` prompts.
137
+
138
+ Each returned `Step` is a `dict` that also supports attribute access (missing
139
+ fields return `None` as attributes):
140
+
141
+ - `index` (`int`): 0-based step index.
142
+ - `type` (`str`): step type, e.g. `"USER_INPUT"`, `"PLANNER_RESPONSE"`,
143
+ `"SYSTEM_MESSAGE"`, or `"GENERIC"` (tool calls).
144
+ - `status` (`str`): e.g. `"DONE"`, `"ERROR"`, or `"CLEARED"`.
145
+ - Message steps set `text` (`str`); tool steps set `tool` (`str`), `args`
146
+ (parsed `dict`), and `output` (`str`, truncated at 200k characters).
147
+
148
+ ```python
149
+ steps = await trajectory(tools=["run_command"], last=20)
150
+ errors = [s.output for s in steps if s.status == "ERROR" and s.output]
151
+ log(f"Found {len(errors)} failed command(s)")
152
+ ```
153
+
154
+ `trajectory()` only returns steps before the `run_workflow` call started (steps
155
+ added while the workflow runs in the background are not included). Older tool
156
+ steps evicted from memory have `status == "CLEARED"` and `output == None`; read
157
+ the conversation's `transcript.jsonl` / `transcript_full.jsonl` when you need
158
+ cleared tool outputs or steps added after the workflow started.
159
+
160
+ ## Behavior to know
161
+
162
+ - Workflow agents are main agents, not subagents. They are hidden from the
163
+ conversation list and reachable from the workflow step. An awaited agent
164
+ is single-use; a called agent lasts until deleted or the workflow ends.
165
+ - `await agent(...)` returns when the agent's run ends, with the result it
166
+ passed to `finish`.
167
+ - If one agent in `parallel` fails, the whole call fails and the other agents
168
+ in it are cancelled. Stopping the parent conversation stops all running
169
+ workflow agents.
170
+ - Agents do not see the script or each other. Put all the context an agent
171
+ needs in its prompt, and ask for a short, well-defined output.
172
+
173
+ ## Example
174
+
175
+ Fan out over a list that an agent produces:
176
+
177
+ ```python
178
+ phase("Discover")
179
+ files = await agent(
180
+ "List the Go files under pkg/foo that call Bar(). Paths only.",
181
+ schema={"type": "array", "items": {"type": "string"}},
182
+ )
183
+
184
+ phase("Review")
185
+ reviews = await parallel(files, lambda f: agent(
186
+ f"Review {f} for misuse of Bar(). Reply in 3 bullets or 'OK'.",
187
+ schema={"type": "string"},
188
+ role=f"Review {f}",
189
+ ))
190
+ for r in reviews:
191
+ log(r)
192
+ ```
package/tsconfig.json CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  // Environment Settings
9
9
  // See also https://aka.ms/tsconfig/module
10
- "module": "nodenext",
10
+ "module": "commonjs",
11
11
  "target": "esnext",
12
12
  "types": ["node"],
13
13
  // For nodejs:
@@ -35,7 +35,7 @@
35
35
  // Recommended Options
36
36
  "strict": true,
37
37
  "jsx": "react-jsx",
38
- "verbatimModuleSyntax": true,
38
+ "verbatimModuleSyntax": false,
39
39
  "isolatedModules": true,
40
40
  "noUncheckedSideEffectImports": true,
41
41
  "moduleDetection": "force",