@keystrokehq/skills 0.0.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.
- package/AGENTS-blurb.md +123 -0
- package/LICENSE +21 -0
- package/README.md +63 -0
- package/keystroke-agent-authoring/SKILL.md +225 -0
- package/keystroke-agent-authoring/evals/evals.json +29 -0
- package/keystroke-agent-authoring/references/messaging-gateways.md +242 -0
- package/keystroke-agent-authoring/references/patterns.md +417 -0
- package/keystroke-agent-authoring/references/prebuilt-integrations.md +879 -0
- package/keystroke-agent-authoring/references/sandbox-and-mcp.md +214 -0
- package/keystroke-agent-authoring/references/source-map.md +182 -0
- package/keystroke-agent-authoring/references/testing.md +85 -0
- package/keystroke-cli-workspace/SKILL.md +93 -0
- package/keystroke-cli-workspace/evals/evals.json +23 -0
- package/keystroke-cli-workspace/references/command-map.md +50 -0
- package/keystroke-cli-workspace/references/credentials-and-connect.md +79 -0
- package/keystroke-cli-workspace/references/project-lifecycle.md +85 -0
- package/keystroke-credential-binding/SKILL.md +509 -0
- package/keystroke-credential-binding/evals/evals.json +29 -0
- package/keystroke-credential-binding/references/cli.md +85 -0
- package/keystroke-credential-binding/references/patterns.md +878 -0
- package/keystroke-credential-binding/references/source-map.md +69 -0
- package/keystroke-data-toolkit/SKILL.md +59 -0
- package/keystroke-data-toolkit/evals/evals.json +23 -0
- package/keystroke-data-toolkit/references/usage.md +79 -0
- package/keystroke-task-authoring/SKILL.md +124 -0
- package/keystroke-task-authoring/evals/evals.json +23 -0
- package/keystroke-task-authoring/references/patterns.md +132 -0
- package/keystroke-task-authoring/references/source-map.md +61 -0
- package/keystroke-trigger-authoring/SKILL.md +189 -0
- package/keystroke-trigger-authoring/evals/evals.json +29 -0
- package/keystroke-trigger-authoring/references/patterns.md +265 -0
- package/keystroke-trigger-authoring/references/source-map.md +128 -0
- package/keystroke-trigger-authoring/references/testing.md +148 -0
- package/keystroke-workflow-as-tool-debugging/SKILL.md +52 -0
- package/keystroke-workflow-as-tool-debugging/evals/evals.json +23 -0
- package/keystroke-workflow-as-tool-debugging/references/playbook.md +77 -0
- package/keystroke-workflow-authoring/SKILL.md +234 -0
- package/keystroke-workflow-authoring/evals/evals.json +29 -0
- package/keystroke-workflow-authoring/references/patterns.md +265 -0
- package/keystroke-workflow-authoring/references/prebuilt-integrations.md +811 -0
- package/keystroke-workflow-authoring/references/runtime-helpers.md +264 -0
- package/keystroke-workflow-authoring/references/source-map.md +108 -0
- package/keystroke-workflow-authoring/references/testing.md +108 -0
- package/package.json +26 -0
package/AGENTS-blurb.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Keystroke Project Context
|
|
2
|
+
|
|
3
|
+
You are working inside a Keystroke project. Keystroke is a code-first workflow and agent automation platform. Authors define workflows, agents, operations, tasks, triggers, messaging gateways, MCP servers, sandboxes, and credential bindings in TypeScript, then build and deploy them with the Keystroke CLI.
|
|
4
|
+
|
|
5
|
+
When reasoning about authored code, use this top-level split:
|
|
6
|
+
|
|
7
|
+
- A `Workflow` is deterministic orchestration. Its `run(...)` method coordinates steps, child workflows, waits, hooks, and agents.
|
|
8
|
+
- An `Agent` is model-driven execution. It runs with agent tools, can use sandboxes, MCP servers, and messaging gateways, and is the right place for llm driven work.
|
|
9
|
+
- A `Task` is the trigger-driven agent path. It combines triggers, a prompt, and an agent run.
|
|
10
|
+
- A workflow can also be registered as an agent tool. Sync workflow tools return inline results; suspending workflow tools yield and resume later; large outputs can return refs inspected with bounded data toolkit tools.
|
|
11
|
+
|
|
12
|
+
Triggers, tasks, and agent conversations are different entry models:
|
|
13
|
+
|
|
14
|
+
- a workflow is started by a trigger or direct invocation
|
|
15
|
+
- a trigger is a code-based primitive you author in TypeScript and attach to a workflow
|
|
16
|
+
- a trigger attaches to a workflow and resolves external payload into validated workflow input
|
|
17
|
+
- a trigger is not a chat session; it is an ingress boundary that transforms payload and starts a workflow
|
|
18
|
+
- a task is not attached with `trigger.attach(...)`; it lists triggers inline and resolves a prompt for an agent run
|
|
19
|
+
- an agent conversation is a chat session, not a code-authored primitive like `CronTrigger`, `WebhookTrigger`, or `PollingTrigger`
|
|
20
|
+
- conversations can be started from the UI, from messaging adapters such as Slack, Linear, or GitHub, or from a workflow when the workflow runs an agent
|
|
21
|
+
- messaging gateways configure conversational entry on agents; they are not workflow triggers
|
|
22
|
+
- an agent keeps full context of the conversation session while the workflow side stays replay-safe and stateless between execution boundaries
|
|
23
|
+
|
|
24
|
+
Keystroke also has one shared unit-of-work primitive: `Operation`.
|
|
25
|
+
|
|
26
|
+
- `Operation`, `Step`, and `Tool` are aliases for the same class from `@keystrokehq/core`.
|
|
27
|
+
- Use the `Step` name when teaching workflow-side usage.
|
|
28
|
+
- Use the `Tool` name when teaching agent-side usage.
|
|
29
|
+
- Use the `Operation` name when describing shared infrastructure, integrations, or a reusable unit that can be used in both places.
|
|
30
|
+
- The runtime behavior comes from context, not from which alias name was used in the constructor.
|
|
31
|
+
|
|
32
|
+
Runtime boundary:
|
|
33
|
+
|
|
34
|
+
- workflows and steps are authored as TypeScript control-flow and unit-of-work code
|
|
35
|
+
- workflows do not run bash commands as part of the workflow authoring model
|
|
36
|
+
- agents are the correct place for bash, filesystem work, and sandbox-managed dependencies such as Python
|
|
37
|
+
|
|
38
|
+
Keystroke workflow execution is replay-based and stateless at the workflow layer:
|
|
39
|
+
|
|
40
|
+
- Keystroke does not persist live in-memory workflow state.
|
|
41
|
+
- Instead, it persists execution events and terminal results for execution boundaries, then replays the workflow code from the top with that saved state.
|
|
42
|
+
- The workflow body itself is re-executed during replay. Local variables and control flow are recomputed, not resumed from memory.
|
|
43
|
+
- Because of that, workflow code must be replay-safe and deterministic.
|
|
44
|
+
|
|
45
|
+
Treat these calls inside `Workflow.run(...)` as execution boundaries:
|
|
46
|
+
|
|
47
|
+
- `await step.run(...)`
|
|
48
|
+
- `await operation.run(...)`
|
|
49
|
+
- `await childWorkflow.run(...)`
|
|
50
|
+
- `await agent.run(...)`
|
|
51
|
+
|
|
52
|
+
What gets persisted:
|
|
53
|
+
|
|
54
|
+
- For steps, Keystroke persists created/completed/failed state and reuses the saved result during workflow replay.
|
|
55
|
+
- For child workflows, Keystroke persists the child run and its terminal result, then resumes the parent workflow with that saved outcome.
|
|
56
|
+
- For agents, Keystroke persists agent execution state and terminal output, then resumes the workflow with that saved result.
|
|
57
|
+
- The workflow's own in-memory logic is not persisted. The platform saves boundary state, not the live workflow stack.
|
|
58
|
+
|
|
59
|
+
Where code runs:
|
|
60
|
+
|
|
61
|
+
- Operations used as workflow steps are low-level units of work and run in separate worker executions.
|
|
62
|
+
- Child workflows run as separate workflow executions in their own workers, using the same replay model as parent workflows.
|
|
63
|
+
- Agents run outside the workflow replay worker. They run in persisted sandboxes with a persistent filesystem, where they can use files, shell commands, installed skills, MCP servers, and other runtime tools. The filesystem persists over all agent runs for a deployed agent.
|
|
64
|
+
- Operations used as agent tools are not top-level orchestration units. A tool runs inside the agent runtime when the agent chooses to call it, inside that persisted sandbox context.
|
|
65
|
+
|
|
66
|
+
Workflow triggers versus agent conversations:
|
|
67
|
+
|
|
68
|
+
- use code-authored triggers when external schedules, webhook requests, or polling results should become workflow input
|
|
69
|
+
- use agent conversations when a user or system is chatting with an agent over time
|
|
70
|
+
- author triggers in code; do not think of conversations as authored primitives in the same way
|
|
71
|
+
- messaging adapters normalize inbound events into thread-based conversations, and the agent responds inside that conversation context
|
|
72
|
+
- a workflow can still start an agent-backed conversation by running an agent, but that is different from a workflow trigger boundary
|
|
73
|
+
|
|
74
|
+
Authoring implications:
|
|
75
|
+
|
|
76
|
+
- Put orchestration, branching, loops, waits, and composition in workflows.
|
|
77
|
+
- Put deterministic side effects and integration calls in operations used as steps.
|
|
78
|
+
- Put LLM-driven reasoning and tool selection in agents.
|
|
79
|
+
- Put concrete callable actions in operations used as tools.
|
|
80
|
+
- Use `largeResultMode: 'ref'` plus `describe_ref`, `read_ref`, and `slice_ref` for large workflow-tool outputs. Reducers and DuckDB-backed data tools are deferred.
|
|
81
|
+
- Use `midSessionSnapshot: true` only for measured workflow-tool cases that need Phase D replay. Current snapshot behavior is conversation-log replay, not native Pi process restore.
|
|
82
|
+
- Do not depend on workflow-local mutable state, random values, direct network I/O, or filesystem mutations in the workflow body itself unless they happen behind a Keystroke execution boundary.
|
|
83
|
+
- Never assume workflow-local memory or filesystem state survives between replays. If state must survive, return it from an operation, agent, or child workflow, or persist it externally.
|
|
84
|
+
|
|
85
|
+
## Workflow Builder File Structure
|
|
86
|
+
|
|
87
|
+
The workflow builder now relies on explicit file structure. Teach and author Keystroke code with one exported primitive per typed file:
|
|
88
|
+
|
|
89
|
+
- `*.workflow.ts` for one `Workflow`
|
|
90
|
+
- `*.step.ts`, `*.tool.ts`, or `*.operation.ts` for one exported `Operation`
|
|
91
|
+
- `*.agent.ts` for one `Agent`
|
|
92
|
+
- `*.gateway.ts` for one `MessagingGateway`
|
|
93
|
+
- `*.trigger.ts` for one trigger
|
|
94
|
+
- `*.credential-set.ts` for one `CredentialSet`
|
|
95
|
+
- `*.mcp-server.ts` for one `McpServer`
|
|
96
|
+
|
|
97
|
+
Builder note:
|
|
98
|
+
|
|
99
|
+
- `*.step.ts`, `*.tool.ts`, and `*.operation.ts` all validate as the same operation convention
|
|
100
|
+
- choose the suffix that communicates intent to the reader
|
|
101
|
+
|
|
102
|
+
Required structure:
|
|
103
|
+
|
|
104
|
+
- exported primitives should be top-level and statically visible
|
|
105
|
+
- helper files such as `schemas.ts`, `utils.ts`, or `prompts.ts` should not export primitives
|
|
106
|
+
- a `*.trigger.ts` file may also export that trigger's `TriggerAttachment` values
|
|
107
|
+
- tests are exempt, but authored project code should follow the typed-file convention everywhere
|
|
108
|
+
|
|
109
|
+
Example layout:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
customer-support/
|
|
113
|
+
crm-api.credential-set.ts
|
|
114
|
+
lookup-customer.tool.ts
|
|
115
|
+
support.agent.ts
|
|
116
|
+
support.gateway.ts
|
|
117
|
+
triage.step.ts
|
|
118
|
+
support.workflow.ts
|
|
119
|
+
support.trigger.ts
|
|
120
|
+
coding.sandbox.ts
|
|
121
|
+
docs.mcp-server.ts
|
|
122
|
+
schemas.ts
|
|
123
|
+
```
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Keystroke
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @keystrokehq/skills
|
|
2
|
+
|
|
3
|
+
Canonical Keystroke-authored agent skills live in this package.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package is the source of truth for Keystroke-specific skills that teach agents how to author Keystroke projects and write code for Keystroke primitives.
|
|
8
|
+
|
|
9
|
+
The packaged skills are:
|
|
10
|
+
|
|
11
|
+
- `keystroke-workflow-authoring`
|
|
12
|
+
- `keystroke-agent-authoring`
|
|
13
|
+
- `keystroke-data-toolkit`
|
|
14
|
+
- `keystroke-workflow-as-tool-debugging`
|
|
15
|
+
- `keystroke-credential-binding`
|
|
16
|
+
- `keystroke-trigger-authoring`
|
|
17
|
+
- `keystroke-task-authoring`
|
|
18
|
+
- `keystroke-cli-workspace`
|
|
19
|
+
|
|
20
|
+
## Editing
|
|
21
|
+
|
|
22
|
+
Edit the source files in `packages/skills/`.
|
|
23
|
+
|
|
24
|
+
Do not treat local editor skill directories as the source of truth for these packaged skills. Edit the canonical files in `packages/skills/` first, then use the Keystroke CLI skill sync flow when local `.cursor/skills` or `.claude/skills` copies need to be refreshed.
|
|
25
|
+
|
|
26
|
+
## Structure
|
|
27
|
+
|
|
28
|
+
Each skill follows this structure:
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
<skill-name>/
|
|
32
|
+
├── SKILL.md
|
|
33
|
+
├── references/
|
|
34
|
+
│ ├── source-map.md
|
|
35
|
+
│ └── ...
|
|
36
|
+
└── evals/
|
|
37
|
+
└── evals.json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- `SKILL.md` stays concise and procedural.
|
|
41
|
+
- `references/` holds longer examples, source maps, and gotchas.
|
|
42
|
+
- `evals/evals.json` stores the initial evaluation prompts used with `.agents/skills/skill-creator/`.
|
|
43
|
+
|
|
44
|
+
## Wiring
|
|
45
|
+
|
|
46
|
+
These packaged skills are intended to be copied into local editor skill directories through the Keystroke CLI:
|
|
47
|
+
|
|
48
|
+
- packaged skills are authored here
|
|
49
|
+
- `keystroke skills sync` copies them into `.cursor/skills` and `.claude/skills`
|
|
50
|
+
|
|
51
|
+
If the discovery story changes later, update this package and the sync flow together. Until then, edit the packaged skills here first.
|
|
52
|
+
|
|
53
|
+
Because these are repo-authored local skills rather than externally installed skills, they do not require new `skills-lock.json` entries.
|
|
54
|
+
|
|
55
|
+
## Authoring Process
|
|
56
|
+
|
|
57
|
+
Draft and refine these skills with the existing `.agents/skills/skill-creator/` workflow:
|
|
58
|
+
|
|
59
|
+
1. Draft the skill
|
|
60
|
+
2. Add realistic eval prompts to `evals/evals.json`
|
|
61
|
+
3. Run at least one evaluation pass
|
|
62
|
+
4. Revise the skill based on results
|
|
63
|
+
5. Improve the `description` once the body is stable
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: keystroke-agent-authoring
|
|
3
|
+
description: Build Keystroke agents with @keystrokehq/core plus provider credentials from @keystroke/integration-ai. Use when the user wants to author, refactor, explain, or test Keystroke agent code, tool code, messaging gateways, sandboxed coding agents, MCP servers, or agent credential wiring.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Keystroke Agent Authoring
|
|
7
|
+
|
|
8
|
+
Use this skill when an agent needs to write or change Keystroke agent code or tool code.
|
|
9
|
+
|
|
10
|
+
Keep this skill focused on authored agent code:
|
|
11
|
+
- use `../keystroke-workflow-authoring/SKILL.md` for workflow orchestration
|
|
12
|
+
- use `../keystroke-data-toolkit/SKILL.md` for refs and large workflow-tool outputs
|
|
13
|
+
- use `../keystroke-workflow-as-tool-debugging/SKILL.md` for workflow-tool run/debug workflows
|
|
14
|
+
- use `../keystroke-task-authoring/SKILL.md` for trigger-driven agent tasks
|
|
15
|
+
- use `../keystroke-trigger-authoring/SKILL.md` for trigger authoring
|
|
16
|
+
- use `../keystroke-credential-binding/SKILL.md` for credential design and binding
|
|
17
|
+
- use `../keystroke-cli-workspace/SKILL.md` for setup, build, deploy, and logs
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
Author one exported primitive per typed file.
|
|
22
|
+
|
|
23
|
+
`crm-api.credential-set.ts`
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { CredentialSet } from '@keystrokehq/core';
|
|
27
|
+
import { z } from 'zod';
|
|
28
|
+
|
|
29
|
+
export const crmCredentials = new CredentialSet({
|
|
30
|
+
id: 'crmApi',
|
|
31
|
+
name: 'CRM API',
|
|
32
|
+
auth: z.object({
|
|
33
|
+
apiKey: z.string(),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`lookup-customer.tool.ts`
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { Tool } from '@keystrokehq/core';
|
|
42
|
+
import { z } from 'zod';
|
|
43
|
+
import { crmCredentials } from './crm-api.credential-set';
|
|
44
|
+
|
|
45
|
+
export const lookupCustomerTool = new Tool({
|
|
46
|
+
id: 'lookup_customer',
|
|
47
|
+
name: 'Lookup Customer',
|
|
48
|
+
description: 'Returns a customer record by email address.',
|
|
49
|
+
credentialSets: [crmCredentials],
|
|
50
|
+
input: z.object({
|
|
51
|
+
email: z.email(),
|
|
52
|
+
}),
|
|
53
|
+
output: z.object({
|
|
54
|
+
customerId: z.string(),
|
|
55
|
+
email: z.email(),
|
|
56
|
+
}),
|
|
57
|
+
run: async (input, ctx) => ({
|
|
58
|
+
customerId: `customer:${ctx.credentials.crmApi.apiKey}:${input.email}`,
|
|
59
|
+
email: input.email,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`support.agent.ts`
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { anthropic } from '@keystroke/integration-ai';
|
|
68
|
+
import { Agent } from '@keystrokehq/core';
|
|
69
|
+
import { lookupCustomerTool } from './lookup-customer.tool';
|
|
70
|
+
|
|
71
|
+
export const supportAgent = new Agent({
|
|
72
|
+
id: 'support-agent',
|
|
73
|
+
name: 'Support Agent',
|
|
74
|
+
description: 'Looks up a customer and drafts a response.',
|
|
75
|
+
systemPrompt:
|
|
76
|
+
'Look up the customer first. Use the tool result in the answer. Do not guess missing data.',
|
|
77
|
+
model: 'anthropic/claude-sonnet-4-20250514',
|
|
78
|
+
credentialSets: [anthropic],
|
|
79
|
+
tools: [lookupCustomerTool],
|
|
80
|
+
maxSteps: 8,
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Authoring model
|
|
85
|
+
|
|
86
|
+
Teach this mental model clearly:
|
|
87
|
+
- an agent is an LLM-driven worker
|
|
88
|
+
- a `Tool` is the agent-facing alias for `Operation`
|
|
89
|
+
- authored agents use `new Agent({...})` from `@keystrokehq/core`
|
|
90
|
+
- AI provider credentials such as `anthropic` and `openai` come from `@keystroke/integration-ai`
|
|
91
|
+
- agents operate through conversations and agent runs, not workflow trigger attachments
|
|
92
|
+
- workflows can call agents, but workflows still own orchestration
|
|
93
|
+
- agents can use workflows as tools; sync workflows return inline and suspending workflows yield/resume
|
|
94
|
+
|
|
95
|
+
## Workflows as tools
|
|
96
|
+
|
|
97
|
+
An agent `tools` array can contain both operations and workflows:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
new Agent({
|
|
101
|
+
id: 'support-agent',
|
|
102
|
+
name: 'Support Agent',
|
|
103
|
+
systemPrompt: 'Help users',
|
|
104
|
+
model: 'anthropic/claude-sonnet-4-20250514',
|
|
105
|
+
credentialSets: [anthropic],
|
|
106
|
+
tools: [lookupCustomerTool, auditAccountWorkflow],
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Workflow tools are classified during build/enrichment. Non-suspending workflows return inline results. Suspending workflows return a `pending: true` yield receipt, end the model's turn, and resume later with the resolved workflow result. If a workflow opts into `midSessionSnapshot: true`, the current Phase D path resumes through scoped conversation-log replay rather than native Pi process restore.
|
|
111
|
+
|
|
112
|
+
Workflow tool outputs are capped before entering LLM context. Workflows with `largeResultMode: 'ref'` can return a small ref envelope for large results; the data toolkit tools `describe_ref`, `read_ref`, and `slice_ref` are auto-injected when workflow tools are present. Reducer tools are not auto-injected.
|
|
113
|
+
|
|
114
|
+
When any yield-mode workflow tool is present, the platform also injects companion tools such as `provide_workflow_response`, `cancel_workflow`, and `check_workflow_status` so the model can resolve hooks, cancel in-flight workflow tools, or check status safely.
|
|
115
|
+
|
|
116
|
+
## Manual API Execution
|
|
117
|
+
|
|
118
|
+
Agents can be interacted with on-demand via the Keystroke API.
|
|
119
|
+
|
|
120
|
+
### Executing an Agent Conversation
|
|
121
|
+
Users can start a new agent conversation directly.
|
|
122
|
+
- **Endpoint**: `POST /api/v1/agents/[agentId]/conversations`
|
|
123
|
+
- **Body requirements**: Needs a `title`.
|
|
124
|
+
- **Response**: Returns the `conversationId` for subsequent interactions.
|
|
125
|
+
|
|
126
|
+
## Conversations, tasks, and gateways
|
|
127
|
+
|
|
128
|
+
Use the right entry language:
|
|
129
|
+
- workflows are entered by triggers
|
|
130
|
+
- tasks are entered by triggers and then resolve a prompt for an agent run
|
|
131
|
+
- agents can also be entered through messaging gateways and conversations
|
|
132
|
+
- a `MessagingGateway` is not a trigger
|
|
133
|
+
- `Agent.messaging` is where agent conversation entrypoints are configured
|
|
134
|
+
|
|
135
|
+
Teach MessagingGateway inside the agent surface:
|
|
136
|
+
- use `MessagingGateway` when the user wants Slack, GitHub, or Linear conversational entry for an agent
|
|
137
|
+
- default to `mode: 'platform'` — a platform app is a Keystroke-owned app that the user installs into their workspace
|
|
138
|
+
- use `mode: 'custom'` only when the user explicitly says they want to create their own app or use an app they already manage
|
|
139
|
+
- do not use `appRef` on platform gateways
|
|
140
|
+
- use `Task` when the user wants “trigger -> prompt -> agent run”
|
|
141
|
+
- use a workflow when the user wants durable orchestration across multiple steps or agents
|
|
142
|
+
|
|
143
|
+
## Runtime boundary
|
|
144
|
+
|
|
145
|
+
Agents are the right place for shell and filesystem-oriented work.
|
|
146
|
+
|
|
147
|
+
Teach these rules explicitly:
|
|
148
|
+
- workflows do not run bash commands as part of their authoring model
|
|
149
|
+
- agents can execute bash commands when they have the appropriate tools and sandbox runtime
|
|
150
|
+
- if the agent needs Python or another binary, it must exist in the sandbox or be installed during sandbox setup
|
|
151
|
+
|
|
152
|
+
## Default agent process
|
|
153
|
+
|
|
154
|
+
1. Decide whether the job really needs an agent.
|
|
155
|
+
2. Write the agent’s job in one sentence.
|
|
156
|
+
3. Look for a prebuilt integration operation before writing a custom tool.
|
|
157
|
+
4. Author the agent with `new Agent({...})`.
|
|
158
|
+
5. Keep each exported primitive in its own typed file.
|
|
159
|
+
6. Add only the tools, credentials, MCP servers, skills, and messaging gateways the job actually needs.
|
|
160
|
+
7. If the agent belongs inside a larger automation, call it from a workflow or task instead of moving orchestration into the agent.
|
|
161
|
+
|
|
162
|
+
## Agent rules
|
|
163
|
+
|
|
164
|
+
- Prefer `new Agent({...})` from `@keystrokehq/core` for authored agents.
|
|
165
|
+
- Prefer `Tool` for custom agent operations.
|
|
166
|
+
- Every custom `Tool` / `Operation` must include a stable `id`.
|
|
167
|
+
- Tool ids must be unique within an agent after integration namespacing.
|
|
168
|
+
- Keep each exported messaging gateway in its own `*.gateway.ts` file.
|
|
169
|
+
- Keep tool selection aligned with the agent’s job.
|
|
170
|
+
- Do not wrap an existing integration operation in a redundant custom tool.
|
|
171
|
+
- Use `CredentialSet` for custom secrets and use provider credential sets from `@keystroke/integration-ai` for model auth.
|
|
172
|
+
- Do not use `process.env` in authored agent or tool code.
|
|
173
|
+
- Expect the default agent sandbox to be persistent.
|
|
174
|
+
- Create a custom `Sandbox` only when the default sandbox needs customization.
|
|
175
|
+
- Follow Zod v4 syntax in examples and authored code. See `../../../.agents/rules/zod-v4-requirements.md`.
|
|
176
|
+
|
|
177
|
+
## Agent Guidelines for Custom Tools & Operations
|
|
178
|
+
|
|
179
|
+
When an agent needs to write custom tools or operations, it must follow these rules:
|
|
180
|
+
1. **Always use prebuilt tools/operations** if they exist before writing custom ones.
|
|
181
|
+
2. **Collect context first**: Do you have all the information you need from the user? If not, ask the user to clarify what they are looking for. **Do Not Guess**.
|
|
182
|
+
3. **Understand API payloads**: If using an API endpoint to fetch data, search the provider's docs to understand the payloads. If possible, hit available endpoints to inspect the actual payloads.
|
|
183
|
+
4. **Always write and run tests**: You must always write tests for new tools and operations. Always run the tests to make sure that the new tools run (see `references/testing.md`).
|
|
184
|
+
5. **Handle missing credentials**: If you cannot run tests because of missing credentials, ask the user to configure them following the `../keystroke-credential-binding/SKILL.md` skill. The user will need to upload credentials before deploying anyway.
|
|
185
|
+
|
|
186
|
+
## Important agent fields
|
|
187
|
+
|
|
188
|
+
Teach these first:
|
|
189
|
+
- `id`
|
|
190
|
+
- `name`
|
|
191
|
+
- `description`
|
|
192
|
+
- `systemPrompt`
|
|
193
|
+
- `model`
|
|
194
|
+
- `tools`
|
|
195
|
+
- `credentialSets`
|
|
196
|
+
- `mcpServers`
|
|
197
|
+
- `sandbox`
|
|
198
|
+
- `messaging`
|
|
199
|
+
- `skills`
|
|
200
|
+
- `maxSteps`
|
|
201
|
+
|
|
202
|
+
Call out these runtime details when relevant:
|
|
203
|
+
- `allCredentialSets` includes credentials from the agent, tools, MCP servers, and messaging gateways
|
|
204
|
+
- `runtimeKind` distinguishes declarative-only agents from runnable or streamable agents
|
|
205
|
+
|
|
206
|
+
## When to choose an agent
|
|
207
|
+
|
|
208
|
+
Choose an agent when the job needs:
|
|
209
|
+
- LLM reasoning in a loop
|
|
210
|
+
- dynamic tool selection
|
|
211
|
+
- coding-agent behavior in a sandbox
|
|
212
|
+
- filesystem work that persists through the agent runtime
|
|
213
|
+
- messaging-based conversational entry
|
|
214
|
+
|
|
215
|
+
Do not choose an agent when a normal workflow step is enough.
|
|
216
|
+
|
|
217
|
+
## References
|
|
218
|
+
|
|
219
|
+
Read these files as needed:
|
|
220
|
+
- `references/source-map.md` for the public agent, tool, sandbox, MCP, and messaging surface
|
|
221
|
+
- `references/patterns.md` for field-by-field agent and tool examples
|
|
222
|
+
- `references/messaging-gateways.md` for gateway authoring
|
|
223
|
+
- `references/sandbox-and-mcp.md` for sandbox runtime, bash, files, MCP, and dependency setup
|
|
224
|
+
- `references/testing.md` for agent and tool testing patterns
|
|
225
|
+
- `references/prebuilt-integrations.md` for integration operations to use in `tools`
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "keystroke-agent-authoring",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "I need a Keystroke agent that can look up Slack users and DM one of them. What fields should I set up, and where do tools and credentials go?",
|
|
7
|
+
"expected_output": "Explains the canonical Keystroke agent path, the important agent fields, tool configuration, and the credential relationship between the agent and its tools.",
|
|
8
|
+
"files": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": 2,
|
|
12
|
+
"prompt": "Should this be a Step or an agent? The task is to inspect some repo files, decide what changed, and then call a couple of tools depending on what it finds.",
|
|
13
|
+
"expected_output": "Explains when an agent is appropriate, when a normal step would be better, and how workflow orchestration relates to agent scope.",
|
|
14
|
+
"files": []
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": 3,
|
|
18
|
+
"prompt": "Show me how to build a sandboxed Keystroke coding agent that can work in a checked-out repo and maybe use MCP later if needed.",
|
|
19
|
+
"expected_output": "Uses the public sandbox and MCP patterns, points to MCP references when needed, and keeps workflow orchestration separate.",
|
|
20
|
+
"files": []
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": 4,
|
|
24
|
+
"prompt": "I want my Keystroke agent to answer messages from GitHub conversations. Should I use a trigger or something else?",
|
|
25
|
+
"expected_output": "Explains that conversational entry belongs on Agent.messaging with a MessagingGateway, not on workflow triggers, and keeps the distinction between tasks, triggers, and conversations clear.",
|
|
26
|
+
"files": []
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|