@kriya-ai/harness 0.0.0-stage → 0.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 (185) hide show
  1. package/README.md +379 -2
  2. package/SAFETY.md +162 -0
  3. package/THIRD_PARTY_NOTICES.md +7911 -0
  4. package/bin/kriya.js +577 -0
  5. package/bundle/cordis.patch.yml +397 -0
  6. package/contract/SOURCE.md +15 -0
  7. package/contract/contract.json +1355 -0
  8. package/package.json +57 -4
  9. package/plugins/anchor/index.js +56 -0
  10. package/plugins/anchor/package.json +13 -0
  11. package/plugins/approvals/index.js +183 -0
  12. package/plugins/approvals/package.json +13 -0
  13. package/plugins/brand/DESIGN.md +112 -0
  14. package/plugins/brand/client.js +826 -0
  15. package/plugins/brand/index.js +15 -0
  16. package/plugins/brand/package.json +25 -0
  17. package/plugins/brand/src/client.js +823 -0
  18. package/plugins/browser/index.js +218 -0
  19. package/plugins/browser/package.json +13 -0
  20. package/plugins/budget/index.js +108 -0
  21. package/plugins/budget/package.json +13 -0
  22. package/plugins/changes/client.js +245 -0
  23. package/plugins/changes/index.js +75 -0
  24. package/plugins/changes/package.json +22 -0
  25. package/plugins/edit/client.js +113 -0
  26. package/plugins/edit/index.js +58 -0
  27. package/plugins/edit/package.json +23 -0
  28. package/plugins/fs-freshness/index.js +28 -0
  29. package/plugins/fs-freshness/package.json +13 -0
  30. package/plugins/graph/client.js +178 -0
  31. package/plugins/graph/index.js +4 -0
  32. package/plugins/graph/package.json +22 -0
  33. package/plugins/kriya-handoff/index.js +194 -0
  34. package/plugins/kriya-handoff/package.json +13 -0
  35. package/plugins/kriya-tools/index.js +189 -0
  36. package/plugins/kriya-tools/package.json +13 -0
  37. package/plugins/loop/index.js +743 -0
  38. package/plugins/loop/package.json +13 -0
  39. package/plugins/mirror/index.js +235 -0
  40. package/plugins/mirror/package.json +13 -0
  41. package/plugins/overview/client.js +276 -0
  42. package/plugins/overview/index.js +95 -0
  43. package/plugins/overview/package.json +22 -0
  44. package/plugins/preview/client.js +337 -0
  45. package/plugins/preview/index.js +4 -0
  46. package/plugins/preview/package.json +22 -0
  47. package/plugins/progress/client.js +290 -0
  48. package/plugins/progress/index.js +100 -0
  49. package/plugins/progress/package.json +22 -0
  50. package/plugins/projects/client.js +249 -0
  51. package/plugins/projects/index.js +30 -0
  52. package/plugins/projects/package.json +24 -0
  53. package/plugins/rea/index.js +256 -0
  54. package/plugins/rea/package.json +10 -0
  55. package/plugins/rea/skill/LICENSE +21 -0
  56. package/plugins/rea/skill/SKILL.md +360 -0
  57. package/plugins/rea/skill/references/android-applications.md +36 -0
  58. package/plugins/rea/skill/references/connection-and-recovery.md +127 -0
  59. package/plugins/rea/skill/references/evidence-workflows.md +71 -0
  60. package/plugins/rea/skill/references/javascript-applications.md +218 -0
  61. package/plugins/rea/skill/references/native-and-artifacts.md +297 -0
  62. package/plugins/rea/skill/references/runtime-observation.md +78 -0
  63. package/plugins/remote/index.js +297 -0
  64. package/plugins/remote/package.json +10 -0
  65. package/plugins/router/index.js +84 -0
  66. package/plugins/router/package.json +13 -0
  67. package/plugins/sessions/client.js +68 -0
  68. package/plugins/sessions/index.js +79 -0
  69. package/plugins/sessions/package.json +20 -0
  70. package/plugins/skills/client.js +504 -0
  71. package/plugins/skills/index.js +166 -0
  72. package/plugins/skills/package.json +23 -0
  73. package/src/api.js +97 -0
  74. package/src/browser.js +286 -0
  75. package/src/changes.js +191 -0
  76. package/src/checkpoints.js +313 -0
  77. package/src/daemon.js +503 -0
  78. package/src/doctor.js +137 -0
  79. package/src/edit/core/anchors.js +102 -0
  80. package/src/edit/core/audio.js +158 -0
  81. package/src/edit/core/faces.js +99 -0
  82. package/src/edit/core/ffmpeg.js +258 -0
  83. package/src/edit/core/handoff.js +220 -0
  84. package/src/edit/core/history.js +90 -0
  85. package/src/edit/core/layout.js +92 -0
  86. package/src/edit/core/mix.js +115 -0
  87. package/src/edit/core/ops.js +602 -0
  88. package/src/edit/core/plan.js +266 -0
  89. package/src/edit/core/project.d.ts +134 -0
  90. package/src/edit/core/project.js +307 -0
  91. package/src/edit/core/reframe.js +125 -0
  92. package/src/edit/core/solver.js +416 -0
  93. package/src/edit/core/time.js +110 -0
  94. package/src/edit/core/tonemap.js +57 -0
  95. package/src/edit/director/ask.js +120 -0
  96. package/src/edit/director/gateway.js +16 -0
  97. package/src/edit/director/revise.js +186 -0
  98. package/src/edit/engine/capabilities.js +33 -0
  99. package/src/edit/engine/captions.js +154 -0
  100. package/src/edit/engine/color.js +269 -0
  101. package/src/edit/engine/confine.js +67 -0
  102. package/src/edit/engine/dna.js +148 -0
  103. package/src/edit/engine/index.js +473 -0
  104. package/src/edit/engine/loudness.js +43 -0
  105. package/src/edit/engine/media.js +57 -0
  106. package/src/edit/engine/motion.js +281 -0
  107. package/src/edit/engine/packs.js +87 -0
  108. package/src/edit/engine/probe.js +101 -0
  109. package/src/edit/engine/receipt.js +123 -0
  110. package/src/edit/engine/tool.js +101 -0
  111. package/src/edit/gates/copy.js +113 -0
  112. package/src/edit/gates/index.js +430 -0
  113. package/src/edit/gates/picture.js +130 -0
  114. package/src/edit/gates/sound.js +58 -0
  115. package/src/edit/gates/speech.js +127 -0
  116. package/src/edit/gates/text.js +196 -0
  117. package/src/edit/gates/text.swift +22 -0
  118. package/src/edit/graph/index.js +139 -0
  119. package/src/edit/graph/journal.js +69 -0
  120. package/src/edit/graph/scheduler.js +79 -0
  121. package/src/edit/host/client.js +58 -0
  122. package/src/edit/host/deliver.js +119 -0
  123. package/src/edit/host/jobs.js +84 -0
  124. package/src/edit/host/main.js +135 -0
  125. package/src/edit/host/paths.js +11 -0
  126. package/src/edit/host/projects.js +415 -0
  127. package/src/edit/host/server.js +391 -0
  128. package/src/edit/host/taste.js +135 -0
  129. package/src/edit/host/tavi.js +417 -0
  130. package/src/edit/host/watch.js +141 -0
  131. package/src/edit/index/db.js +109 -0
  132. package/src/edit/index/index.js +236 -0
  133. package/src/edit/index/layers/faces.js +78 -0
  134. package/src/edit/index/layers/faces.swift +18 -0
  135. package/src/edit/index/layers/meta.js +35 -0
  136. package/src/edit/index/layers/music.js +146 -0
  137. package/src/edit/index/layers/quality.js +120 -0
  138. package/src/edit/index/layers/retakes.js +132 -0
  139. package/src/edit/index/layers/screen.js +99 -0
  140. package/src/edit/index/layers/shots.js +29 -0
  141. package/src/edit/index/layers/sound.js +42 -0
  142. package/src/edit/index/layers/words.js +64 -0
  143. package/src/edit/index/story.js +248 -0
  144. package/src/edit/index/views.js +71 -0
  145. package/src/edit/loop/governor.js +112 -0
  146. package/src/edit/loop/loop.js +69 -0
  147. package/src/edit/loop/make.js +115 -0
  148. package/src/edit/loop/repair.js +97 -0
  149. package/src/edit/loop/replay.js +32 -0
  150. package/src/edit/recipes/multicam.js +461 -0
  151. package/src/edit/recipes/reel.js +202 -0
  152. package/src/edit/recipes/short-from-long.js +237 -0
  153. package/src/edit/recipes/tutorial.js +137 -0
  154. package/src/edit/recipes/youtube.js +155 -0
  155. package/src/edit/runtime/cli.js +126 -0
  156. package/src/edit/runtime/doctor.js +122 -0
  157. package/src/edit/runtime/fetch.js +15 -0
  158. package/src/edit/runtime/licences.js +88 -0
  159. package/src/edit/runtime/manifest.js +73 -0
  160. package/src/edit/runtime/setup.js +252 -0
  161. package/src/failure.js +69 -0
  162. package/src/gateway-proxy.js +213 -0
  163. package/src/intent.js +130 -0
  164. package/src/launch.js +315 -0
  165. package/src/live.js +81 -0
  166. package/src/local-skills.js +284 -0
  167. package/src/login.js +82 -0
  168. package/src/loop.js +428 -0
  169. package/src/modes.js +128 -0
  170. package/src/overview.js +71 -0
  171. package/src/paths.js +30 -0
  172. package/src/profiles.js +92 -0
  173. package/src/projects.js +104 -0
  174. package/src/recon.js +244 -0
  175. package/src/rules.js +139 -0
  176. package/src/runner.bundle.js +21172 -0
  177. package/src/sentinel.js +248 -0
  178. package/src/skill-switches.js +130 -0
  179. package/src/store.js +58 -0
  180. package/src/strict.js +124 -0
  181. package/src/verify.js +659 -0
  182. package/src/world.js +268 -0
  183. package/studio/dist/index.html +14 -0
  184. package/studio/dist/studio.css +163 -0
  185. package/studio/dist/studio.js +1 -0
@@ -0,0 +1,194 @@
1
+ import { execFile } from "node:child_process"
2
+ import { createHash } from "node:crypto"
3
+ import { mkdtempSync, rmSync } from "node:fs"
4
+ import { tmpdir } from "node:os"
5
+ import { join } from "node:path"
6
+
7
+ import { call } from "../../src/api.js"
8
+
9
+ // Handoff and pull (H8, HD-11; docs/kriya-harness/ARCHITECTURE.md §3.4 in
10
+ // the Kriya repository).
11
+ // - `kriya handoff [note]`: the repository's HEAD must be on GitHub; the
12
+ // working tree against HEAD (untracked files included, ignored ones left
13
+ // out) becomes one binary patch in track C's checkpoint format, uploaded
14
+ // with its sha256 to POST /handoff. A Kriya agent then carries on in a
15
+ // cloud workspace.
16
+ // - `kriya pull [workspaceId]`: the workspace's latest checkpoint, checked
17
+ // against its sha256, applied on a new branch kriya/pull-<id> at the
18
+ // workspace's base commit. The person's own branch is never touched.
19
+ // Nothing here runs a command the person didn't ask for beyond git.
20
+
21
+ const UPLOAD_MS = 5 * 60_000
22
+ // The person's note (the contract's limit)
23
+ const NOTE_MAX = 2000
24
+ const MB = 1024 * 1024
25
+
26
+ export class HandoffError extends Error {}
27
+
28
+ /**
29
+ * git in `cwd`; stdout as a Buffer
30
+ * @param {string} cwd
31
+ * @param {string[]} args
32
+ * @param {{ input?: Buffer, env?: NodeJS.ProcessEnv }} [options]
33
+ */
34
+ function git(cwd, args, { input, env } = {}) {
35
+ return new Promise((resolve, reject) => {
36
+ const child = execFile(
37
+ "git",
38
+ args,
39
+ { cwd, env: env ?? process.env, encoding: "buffer", maxBuffer: 1024 * MB },
40
+ (error, stdout, stderr) => {
41
+ if (error) {
42
+ const detail = stderr.toString().trim().split("\n")[0] || error.message
43
+ reject(new HandoffError(detail))
44
+ } else resolve(stdout)
45
+ }
46
+ )
47
+ if (input) child.stdin.end(input)
48
+ })
49
+ }
50
+
51
+ const text = async (cwd, args) => (await git(cwd, args)).toString().trim()
52
+
53
+ async function repoRoot(cwd) {
54
+ try {
55
+ return await text(cwd, ["rev-parse", "--show-toplevel"])
56
+ } catch {
57
+ throw new HandoffError("This folder isn't a git repository; run kriya handoff inside one.")
58
+ }
59
+ }
60
+
61
+ /** owner/name from a GitHub remote URL (https, ssh or scp form); null otherwise */
62
+ export function githubRepo(remote) {
63
+ const match = /^(?:https:\/\/(?:[^@/]+@)?github\.com\/|ssh:\/\/git@github\.com\/|git@github\.com:)([A-Za-z0-9-]{1,39})\/([A-Za-z0-9._-]{1,100}?)(?:\.git)?\/?$/.exec(
64
+ remote.trim()
65
+ )
66
+ return match ? `${match[1]}/${match[2]}` : null
67
+ }
68
+
69
+ /**
70
+ * The working tree against HEAD as track C's runner writes a checkpoint:
71
+ * `git diff --cached --binary --no-renames HEAD` over a throwaway index that
72
+ * has every file added, so untracked files come along and the person's own
73
+ * index is never changed.
74
+ * @param {string} root
75
+ */
76
+ export async function checkpointPatch(root) {
77
+ const dir = mkdtempSync(join(tmpdir(), "kriya-handoff-"))
78
+ const env = { ...process.env, GIT_INDEX_FILE: join(dir, "index") }
79
+ try {
80
+ await git(root, ["read-tree", "HEAD"], { env })
81
+ await git(root, ["add", "-A"], { env })
82
+ return await git(root, ["diff", "--cached", "--binary", "--no-renames", "HEAD"], { env })
83
+ } finally {
84
+ rmSync(dir, { recursive: true, force: true })
85
+ }
86
+ }
87
+
88
+ const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex")
89
+
90
+ /**
91
+ * What a handoff sends, without sending it: the checks HD-11 asks of the
92
+ * client (a GitHub repository, a branch, HEAD pushed) and the patch.
93
+ * @param {string} cwd
94
+ * @param {string} [note]
95
+ */
96
+ export async function prepareHandoff(cwd, note = "") {
97
+ if (note.length > NOTE_MAX) throw new HandoffError(`The note is over ${NOTE_MAX} characters.`)
98
+ const root = await repoRoot(cwd)
99
+ let baseSha
100
+ try {
101
+ baseSha = await text(root, ["rev-parse", "--verify", "HEAD^{commit}"])
102
+ } catch {
103
+ throw new HandoffError("This repository has no commits yet; commit and push first.")
104
+ }
105
+ const baseRef = await text(root, ["rev-parse", "--abbrev-ref", "HEAD"])
106
+ if (baseRef === "HEAD") throw new HandoffError("HEAD is detached; check out a branch first.")
107
+ let remote = ""
108
+ try {
109
+ remote = await text(root, ["remote", "get-url", "origin"])
110
+ } catch {}
111
+ const repo = githubRepo(remote)
112
+ if (!repo) throw new HandoffError("The origin remote isn't a GitHub repository; Kriya works from GitHub.")
113
+ // The cloud workspace starts from GitHub at this commit (HD-11)
114
+ const pushed = await text(root, ["branch", "-r", "--contains", baseSha])
115
+ if (!pushed) throw new HandoffError(`Commit ${baseSha.slice(0, 12)} isn't on GitHub yet; push your branch first.`)
116
+ const patch = await checkpointPatch(root)
117
+ return {
118
+ meta: {
119
+ repo,
120
+ baseRef,
121
+ baseSha,
122
+ ...(note.trim() && { note: note.trim() }),
123
+ sha256: sha256(patch),
124
+ bytes: patch.length,
125
+ },
126
+ patch,
127
+ }
128
+ }
129
+
130
+ /**
131
+ * @param {{ url: string, token: string }} device
132
+ * @param {string} cwd
133
+ * @param {string} [note]
134
+ * @returns {Promise<{ threadId: string, workspaceId: string, taskId: string, url: string, bytes: number }>}
135
+ */
136
+ export async function handoff(device, cwd, note) {
137
+ const { meta, patch } = await prepareHandoff(cwd, note)
138
+ const form = new FormData()
139
+ form.set("meta", JSON.stringify(meta))
140
+ form.set("patch", new Blob([patch], { type: "application/octet-stream" }), "checkpoint.patch")
141
+ const answer = await call(device.url, "POST", "/handoff", {
142
+ token: device.token,
143
+ body: form,
144
+ signal: AbortSignal.timeout(UPLOAD_MS),
145
+ })
146
+ return { ...answer, bytes: meta.bytes }
147
+ }
148
+
149
+ /**
150
+ * @param {{ url: string, token: string }} device
151
+ * @param {string} cwd
152
+ * @param {string} workspaceId
153
+ * @returns {Promise<{ branch: string, baseSha: string, bytes: number }>}
154
+ */
155
+ export async function pull(device, cwd, workspaceId) {
156
+ if (!/^[0-9a-f-]{36}$/.test(workspaceId)) throw new HandoffError("That isn't a workspace id.")
157
+ const root = await repoRoot(cwd)
158
+ if ((await text(root, ["status", "--porcelain"])) !== "")
159
+ throw new HandoffError("This repository has uncommitted changes; commit or stash them first.")
160
+ const branch = `kriya/pull-${workspaceId}`
161
+ const taken = await git(root, ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`]).then(
162
+ () => true,
163
+ () => false
164
+ )
165
+ if (taken) throw new HandoffError(`Branch ${branch} already exists; delete it or switch to it.`)
166
+
167
+ const response = await call(device.url, "GET", `/workspaces/${workspaceId}/checkpoint`, {
168
+ token: device.token,
169
+ raw: true,
170
+ signal: AbortSignal.timeout(UPLOAD_MS),
171
+ })
172
+ const patch = Buffer.from(await response.arrayBuffer())
173
+ const expected = response.headers.get("x-kriya-sha256")
174
+ const baseSha = response.headers.get("x-kriya-base-sha") ?? ""
175
+ if (!expected || sha256(patch) !== expected)
176
+ throw new HandoffError("The checkpoint was damaged on the way; nothing was applied. Pull again.")
177
+ if (!/^[0-9a-f]{40}$/.test(baseSha)) throw new HandoffError("Kriya didn't say which commit the work starts from.")
178
+ try {
179
+ await git(root, ["cat-file", "-e", `${baseSha}^{commit}`])
180
+ } catch {
181
+ throw new HandoffError(`Commit ${baseSha.slice(0, 12)} isn't in this clone; run git fetch and pull again.`)
182
+ }
183
+
184
+ await git(root, ["switch", "--quiet", "-c", branch, baseSha])
185
+ try {
186
+ if (patch.length) await git(root, ["apply", "--binary", "--whitespace=nowarn", "-"], { input: patch })
187
+ } catch (error) {
188
+ // git apply is all or nothing; put the person back where they were
189
+ await git(root, ["checkout", "--quiet", "-"])
190
+ await git(root, ["branch", "-D", "--quiet", branch])
191
+ throw new HandoffError(`The checkpoint doesn't apply cleanly (${error.message}); nothing was changed.`)
192
+ }
193
+ return { branch, baseSha, bytes: patch.length }
194
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@kriya-ai/harness-handoff",
3
+ "description": "Handoff and pull for the Kriya Harness: hand a repository's uncommitted work to a Kriya cloud workspace, and pull a workspace's changes back onto a new branch",
4
+ "version": "0.1.0",
5
+ "private": true,
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "license": "UNLICENSED"
13
+ }
@@ -0,0 +1,189 @@
1
+ import { defineTool } from "@deepseek-ai/dsh-tools"
2
+
3
+ import { call, deviceFromEnv } from "../../src/api.js"
4
+ import { switchProvider } from "../../src/skill-switches.js"
5
+
6
+ // Kriya's skills and memory inside DeepSeek Harness (H7, HD-10):
7
+ // - a skill source in DSH's registry (`ctx.skills`): the device agent's
8
+ // Kriya skills, ranked below the person's own local skills so theirs win
9
+ // a name, bodies fetched once per version;
10
+ // - `kriya_memory_search`: the notes the device's agent can see in Kriya;
11
+ // - `kriya_memory_save`: a note saved to Kriya, always unconfirmed until
12
+ // the person confirms it there (what runs on this machine is untrusted to
13
+ // Kriya);
14
+ // - the skill switches (src/skill-switches.js): skills the person turned off
15
+ // for a project or everywhere leave the catalog, in every profile.
16
+ // No connector tools: those run only in Kriya's own worker (invariant 5).
17
+
18
+ export const name = "kriya-tools"
19
+ export const inject = ["tools", "skills"]
20
+
21
+ // The list is rechecked (with its ETag) at most once a minute
22
+ const LIST_TTL = 60_000
23
+ // Higher ranks lose a duplicate name: local skills come first
24
+ const RANK = 100
25
+ const SIGNED_OUT = "Kriya Harness is signed out; run kriya login to use Kriya's memory."
26
+
27
+ /** @param {{ now?: () => number }} [options] */
28
+ export function kriyaSkills({ now = Date.now } = {}) {
29
+ let cached = null
30
+ const bodies = new Map()
31
+
32
+ const candidate = (skill) => ({
33
+ name: skill.id,
34
+ description: skill.description,
35
+ whenToUse: `A Kriya skill (${skill.name}, v${skill.version}). Use when the request is about: ${skill.activation.keywords.slice(0, 12).join(", ")}.`,
36
+ invocation: { modelInvocable: true, userInvocable: true },
37
+ source: "custom",
38
+ provider: "kriya",
39
+ rank: RANK,
40
+ locator: { id: skill.id, version: skill.version },
41
+ })
42
+
43
+ return {
44
+ name: "kriya",
45
+ async list({ signal } = {}) {
46
+ const device = deviceFromEnv()
47
+ if (!device) return []
48
+ if (cached && now() - cached.at < LIST_TTL) return cached.candidates
49
+ try {
50
+ const response = await call(device.url, "GET", "/skills", {
51
+ token: device.token,
52
+ signal,
53
+ raw: true,
54
+ headers: cached ? { "If-None-Match": cached.etag } : {},
55
+ })
56
+ if (response.status !== 304) {
57
+ const { skills } = await response.json()
58
+ cached = { etag: response.headers.get("etag") ?? "", candidates: skills.map(candidate) }
59
+ }
60
+ cached.at = now()
61
+ return cached.candidates
62
+ } catch {
63
+ // Kriya unreachable: the last list stays, and DSH keeps its last good catalog
64
+ return { candidates: cached?.candidates ?? [], complete: false }
65
+ }
66
+ },
67
+ async get(found, { signal } = {}) {
68
+ const device = deviceFromEnv()
69
+ const { id, version } = found.locator
70
+ const key = `${id}@${version}`
71
+ if (!bodies.has(key)) {
72
+ if (!device) return undefined
73
+ try {
74
+ const response = await call(device.url, "GET", `/skills/${id}/${version}`, {
75
+ token: device.token,
76
+ signal,
77
+ raw: true,
78
+ })
79
+ bodies.set(key, await response.text())
80
+ } catch {
81
+ return undefined
82
+ }
83
+ }
84
+ const { rank: _rank, locator: _locator, ...summary } = found
85
+ return { ...summary, content: bodies.get(key) }
86
+ },
87
+ }
88
+ }
89
+
90
+ const signedIn = () => {
91
+ const device = deviceFromEnv()
92
+ if (!device) throw new Error(SIGNED_OUT)
93
+ return device
94
+ }
95
+
96
+ const NOTE = {
97
+ type: "object",
98
+ additionalProperties: false,
99
+ properties: {
100
+ id: { type: "string", required: true },
101
+ content: { type: "string", required: true },
102
+ kind: { type: "string", required: true },
103
+ confirmed: { type: "boolean", required: true },
104
+ shared: { type: "boolean", required: true },
105
+ },
106
+ }
107
+
108
+ export const memorySearch = defineTool({
109
+ name: "kriya_memory_search",
110
+ description:
111
+ "Search the person's Kriya memory: the notes their Kriya agent keeps (preferences, facts, decisions). Unconfirmed notes haven't been checked by the person yet.",
112
+ parameters: {
113
+ query: { type: "string", required: true, description: "Words to look for, up to 500 characters." },
114
+ limit: { type: "number", description: "How many notes, 1 to 20 (default 8)." },
115
+ },
116
+ output: {
117
+ schema: {
118
+ type: "object",
119
+ additionalProperties: false,
120
+ properties: { notes: { type: "array", required: true, items: NOTE } },
121
+ },
122
+ render: (_args, value) => [
123
+ {
124
+ type: "text",
125
+ text: value.notes.length
126
+ ? value.notes
127
+ .map((n) => `- ${n.confirmed ? "" : "(unconfirmed) "}${n.shared ? "(shared) " : ""}${n.content}`)
128
+ .join("\n")
129
+ : "No notes in Kriya match that.",
130
+ },
131
+ ],
132
+ },
133
+ async execute(args, exec) {
134
+ const device = signedIn()
135
+ const body = {
136
+ query: String(args.query).slice(0, 500),
137
+ ...(args.limit !== undefined && { limit: Math.min(20, Math.max(1, Math.trunc(args.limit))) }),
138
+ }
139
+ const { notes } = await call(device.url, "POST", "/memory/search", {
140
+ token: device.token,
141
+ body,
142
+ signal: exec.signal,
143
+ })
144
+ return { notes }
145
+ },
146
+ presentCall: (args) => ({ card: "generic", title: "Search Kriya memory", kind: "read", rawInput: String(args.query) }),
147
+ })
148
+
149
+ export const memorySave = defineTool({
150
+ name: "kriya_memory_save",
151
+ description:
152
+ "Save one short note (a fact, preference or decision, up to 1000 characters) to the person's Kriya memory for their agent. It stays unconfirmed until they confirm it in Kriya. Never save passwords, card numbers, OTPs or other secrets.",
153
+ parameters: {
154
+ content: { type: "string", required: true, description: "The note, one fact per note." },
155
+ },
156
+ output: {
157
+ schema: {
158
+ type: "object",
159
+ additionalProperties: false,
160
+ properties: {
161
+ id: { type: "string", required: true },
162
+ confirmed: { type: "boolean", required: true },
163
+ },
164
+ },
165
+ render: () => [
166
+ {
167
+ type: "text",
168
+ text: "Saved to Kriya. It stays unconfirmed until the person confirms it in Kriya.",
169
+ },
170
+ ],
171
+ },
172
+ async execute(args, exec) {
173
+ const device = signedIn()
174
+ const saved = await call(device.url, "POST", "/memory", {
175
+ token: device.token,
176
+ body: { content: String(args.content) },
177
+ signal: exec.signal,
178
+ })
179
+ return { id: saved.id, confirmed: saved.confirmed }
180
+ },
181
+ presentCall: (args) => ({ card: "generic", title: "Save to Kriya memory", kind: "edit", rawInput: String(args.content) }),
182
+ })
183
+
184
+ export function apply(ctx) {
185
+ ctx.skills.registerProvider(() => kriyaSkills())
186
+ ctx.skills.registerProvider((control) => switchProvider(control))
187
+ ctx.tools.register(memorySearch)
188
+ ctx.tools.register(memorySave)
189
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@kriya-ai/harness-tools",
3
+ "description": "Kriya skills and memory inside the Kriya Harness: a DeepSeek Harness skill source and two memory tools",
4
+ "version": "0.1.0",
5
+ "private": true,
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "license": "UNLICENSED"
13
+ }