@h1r-ai/croche 0.5.0 → 0.5.2
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/README.md +23 -15
- package/dist/core-bindgen.js +18 -18
- package/dist/core-runtime.d.ts +1 -1
- package/dist/core-runtime.js +1 -1
- package/dist/core-wasm-bytes.d.ts +3 -3
- package/dist/core-wasm-bytes.js +3 -3
- package/dist/project-types.d.ts +2 -2
- package/dist/types.d.ts +6 -8
- package/docs/CODING-AGENT.md +11 -7
- package/docs/SKILL.md +309 -265
- package/docs/skills/croche/agents/openai.yaml +4 -0
- package/docs/skills/croche/references/agents.md +78 -0
- package/docs/skills/croche/references/first-turn.md +74 -0
- package/docs/skills/croche/references/tools.md +43 -0
- package/docs/skills/croche/references/web-search.md +85 -0
- package/docs/skills/croche-cli/SKILL.md +158 -0
- package/docs/skills/croche-cli/agents/openai.yaml +4 -0
- package/docs/skills/croche-cli/references/powershell.md +47 -0
- package/docs/skills/croche-config/SKILL.md +153 -0
- package/docs/skills/croche-config/agents/openai.yaml +4 -0
- package/docs/skills/croche-config/references/models.md +12 -0
- package/docs/skills/croche-platforms/SKILL.md +55 -0
- package/docs/skills/croche-platforms/agents/openai.yaml +4 -0
- package/docs/skills/croche-platforms/references/android.md +185 -0
- package/docs/skills/croche-platforms/references/ios.md +165 -0
- package/docs/skills/croche-platforms/references/react-native.md +50 -0
- package/docs/skills/croche-platforms/references/web-backend.md +58 -0
- package/docs/skills/croche-troubleshoot/SKILL.md +72 -0
- package/docs/skills/croche-troubleshoot/agents/openai.yaml +4 -0
- package/docs/skills/croche-troubleshoot/references/recovery.md +31 -0
- package/package.json +1 -1
- package/src/core-bindgen.ts +18 -18
- package/src/core-runtime.ts +1 -1
- package/src/core-wasm-bytes.ts +3 -3
- package/src/project-types.ts +2 -2
- package/src/types.ts +6 -8
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Allowed model IDs
|
|
2
|
+
|
|
3
|
+
Use an exact ID below for the `model` field in a Croche project config. These are the IDs
|
|
4
|
+
supported by the current SDK candidate; public package availability remains pending verification.
|
|
5
|
+
|
|
6
|
+
{{ALLOWED_MODEL_IDS}}
|
|
7
|
+
|
|
8
|
+
A model ID outside this list is not a supported app config choice. Match the list to the SDK
|
|
9
|
+
version you actually ship; do not invent IDs or infer input support from another product's catalog.
|
|
10
|
+
For recommendations, config levels and default/fallback behavior, read
|
|
11
|
+
[the config skill](../SKILL.md) or the online [Models page](https://docs.croche.ai/models.md).
|
|
12
|
+
The [documentation index](https://docs.croche.ai/llms.txt) lists every public Markdown page.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: croche-platforms
|
|
3
|
+
description: Set up Croche for React Native, a web backend, or native Swift/Kotlin. Use for platform imports, storage, development versus server credentials, mobile locale, and native release readiness. Not for ordinary Node first-turn setup or generic platform development without Croche.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Choose the correct platform integration
|
|
7
|
+
|
|
8
|
+
Preserve the user's target platform. Explain what is ready and what needs verification rather
|
|
9
|
+
than silently converting their app to another platform. Croche runs the model for the app;
|
|
10
|
+
use the usage and limits shown in Studio, not a separate model-service setup.
|
|
11
|
+
|
|
12
|
+
| Target | Path | Read when needed |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| Local Node check | `@h1r-ai/croche`, durable `FileStorage`, SDK debug key | Core `croche` skill |
|
|
15
|
+
| React Native | `Croche` from `@h1r-ai/croche-react-native`, SDK-managed storage | [react-native.md](references/react-native.md) |
|
|
16
|
+
| Web (local and production) | `Croche` on the app's Node backend, server key stays there | [web-backend.md](references/web-backend.md) |
|
|
17
|
+
| iOS · Swift | SPM, exact **0.5.2**, `Croche.open` | [ios.md](references/ios.md) |
|
|
18
|
+
| Android · Kotlin | Maven, exact **0.5.2**, `Croche.open` | [android.md](references/android.md) |
|
|
19
|
+
|
|
20
|
+
Node.js 22+ on macOS/Linux; Windows verification pending. PowerShell syntax does not establish
|
|
21
|
+
Windows support. SDK 0.5.2 is published on npm; verify the installed version and platform behavior.
|
|
22
|
+
Node and RN do not automatically load the CLI-created `.env`: Node needs `--env-file` or an
|
|
23
|
+
existing dotenv loader, web secrets stay server-side only, and RN needs debug-only build config
|
|
24
|
+
with no secret in release artifacts. Read the matching reference above before the first turn.
|
|
25
|
+
For account CLI login and shell syntax, use `croche-cli` if installed; a `dk_` key is
|
|
26
|
+
never an app credential.
|
|
27
|
+
|
|
28
|
+
## Language option on every platform
|
|
29
|
+
|
|
30
|
+
`language` is the **user's BCP-47 language**, selecting a translated `config.languages` branch.
|
|
31
|
+
No match uses the base as written in `config.defaultLanguage`; it does not force a reply
|
|
32
|
+
language. Omitted language uses browser `navigator.language`; RN/Swift/Kotlin automatic device
|
|
33
|
+
locale is targeted for 0.5.1 (TODO verify). Pass the known user locale explicitly on earlier RN
|
|
34
|
+
or a Node backend. The model replies to the user's language unless instructions say otherwise.
|
|
35
|
+
Use `croche-config` for the complete selection and next-open rules.
|
|
36
|
+
|
|
37
|
+
## Native gate
|
|
38
|
+
|
|
39
|
+
**Native Swift and Kotlin SDKs are published as 0.5.2**, including the shared
|
|
40
|
+
**project/agent `Croche.open` API**. Do not describe published SDKs as nonexistent.
|
|
41
|
+
Installation and `Croche.open` first-turn examples are in [ios.md](references/ios.md)
|
|
42
|
+
and [android.md](references/android.md). For a native request, read the matching reference,
|
|
43
|
+
prepare the integration and resolve exactly 0.5.2. Verify simulator/emulator first turn
|
|
44
|
+
and release credential exclusion in the target app. Do not substitute the native
|
|
45
|
+
0.5.0 single-agent API or claim an example was run without running it. Use git-ignored `.xcconfig` (iOS) or
|
|
46
|
+
`local.properties` (Android), wired only into Debug and excluded from Release at build time.
|
|
47
|
+
If a native release is unavailable, report that blocker; offer TypeScript/React Native for a
|
|
48
|
+
new hackathon app, but never rewrite an existing native app into a different stack unasked.
|
|
49
|
+
|
|
50
|
+
## Verify the actual target
|
|
51
|
+
|
|
52
|
+
Build and run on the selected simulator/emulator/backend; note its SDK version and OS.
|
|
53
|
+
Check one completed reply and persistence, and inspect a release bundle/config to ensure it
|
|
54
|
+
does not contain development or CLI credentials. Production app verification is configured
|
|
55
|
+
by the user at **Settings → App verification**; a simulator check does not verify a device release.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Android · Kotlin project API
|
|
2
|
+
|
|
3
|
+
Use this guide for a native Android app, not the single-agent API. It targets **0.5.2** and
|
|
4
|
+
`Croche.open` → `agent()` → `request()`.
|
|
5
|
+
|
|
6
|
+
> Version 0.5.2 is published on Maven. Verify Gradle integration, emulator first turn and
|
|
7
|
+
> release credential exclusion in the target app; package publication is not proof of those checks.
|
|
8
|
+
> If the exact package cannot be resolved, report that blocker; do not downgrade the API.
|
|
9
|
+
|
|
10
|
+
## Install from Maven
|
|
11
|
+
|
|
12
|
+
Requires **minSdk 26+**. Add the repository to the existing `settings.gradle.kts` repositories:
|
|
13
|
+
|
|
14
|
+
```kotlin
|
|
15
|
+
dependencyResolutionManagement {
|
|
16
|
+
repositories {
|
|
17
|
+
google()
|
|
18
|
+
mavenCentral()
|
|
19
|
+
maven("https://maven.croche.ai")
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Add the exact dependency in `app/build.gradle.kts`:
|
|
25
|
+
|
|
26
|
+
```kotlin
|
|
27
|
+
dependencies {
|
|
28
|
+
implementation("ai.croche:croche-android:0.5.2")
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The distribution supplies the native binary and dependency metadata. No manual Rust/NDK build
|
|
33
|
+
or copied AAR is needed for this install path. Preserve the app's existing Android/Kotlin setup.
|
|
34
|
+
Windows verification is pending; these Gradle examples are not a Windows support claim.
|
|
35
|
+
|
|
36
|
+
## One human step; the agent sets up the project
|
|
37
|
+
|
|
38
|
+
The coding agent installs the CLI with permission. The human signs up at
|
|
39
|
+
[Studio](https://studio.croche.ai), creates one account key under **Account → Account keys**, and
|
|
40
|
+
runs **`croche login`** privately. Never ask for a key in chat or run login for them. Reuse a
|
|
41
|
+
confirmed login. After the human says done, re-check authentication and the private key file,
|
|
42
|
+
then continue setup and the first authorized live turn in the same turn. Capture CLI JSON
|
|
43
|
+
privately; emit only success/IDs/file paths, never raw output, prefixes or any part of a key.
|
|
44
|
+
For key checks, presence/length only. The agent creates/reuses the project and obtains its **public** project key:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
croche auth whoami --json
|
|
48
|
+
croche projects create --name "My app" --json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Do not request a public project key or SDK debug key from the user. The account key
|
|
52
|
+
is only for CLI authentication; it never goes in the app.
|
|
53
|
+
|
|
54
|
+
## Keep the debug key in local.properties, Debug only
|
|
55
|
+
|
|
56
|
+
Android does not load the CLI's default `.env`. From the Android project root, verify that
|
|
57
|
+
`local.properties` is git-ignored and not tracked, then have the agent run:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
croche debug-keys create --project PROJECT_ID --env-file local.properties --json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use the project ID returned above. The CLI preserves existing entries such as `sdk.dir` and
|
|
64
|
+
writes `CROCHE_DEBUG_KEY` without printing its secret. It refuses an existing nonempty key
|
|
65
|
+
unless force is explicitly approved. Never use secret-print output or show the file. Existing
|
|
66
|
+
file permissions are preserved: restrict them to the user without displaying contents; Windows
|
|
67
|
+
file-protection verification is still pending. Git-ignore is not release protection.
|
|
68
|
+
|
|
69
|
+
In `app/build.gradle.kts`, load the private setting into the **Debug build type only** and use an
|
|
70
|
+
empty value for **Release**. Merge this with existing configuration rather than replacing it:
|
|
71
|
+
|
|
72
|
+
```kotlin
|
|
73
|
+
import java.util.Properties
|
|
74
|
+
|
|
75
|
+
val crocheLocal = Properties().apply {
|
|
76
|
+
val localFile = rootProject.file("local.properties")
|
|
77
|
+
if (localFile.isFile) localFile.inputStream().use { load(it) }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
android {
|
|
81
|
+
defaultConfig { minSdk = 26 }
|
|
82
|
+
buildFeatures { buildConfig = true }
|
|
83
|
+
buildTypes {
|
|
84
|
+
getByName("debug") {
|
|
85
|
+
val key = crocheLocal.getProperty("CROCHE_DEBUG_KEY", "")
|
|
86
|
+
require(key.isEmpty() || Regex("cdt_[a-f0-9]{64}").matches(key)) {
|
|
87
|
+
"Invalid Croche debug-key format."
|
|
88
|
+
}
|
|
89
|
+
buildConfigField("String", "CROCHE_DEBUG_KEY", "\"$key\"")
|
|
90
|
+
}
|
|
91
|
+
getByName("release") {
|
|
92
|
+
buildConfigField("String", "CROCHE_DEBUG_KEY", "\"\"")
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Do not put the key in `defaultConfig`, resources, the manifest, assets or a shared build field.
|
|
99
|
+
Apply the same exclusion to any custom distribution build types; never copy `local.properties`
|
|
100
|
+
or `.env` into the app. A runtime `BuildConfig.DEBUG` check alone cannot remove an embedded secret.
|
|
101
|
+
Keep verbose build output and build caches containing Debug artifacts private. See Android's
|
|
102
|
+
[build configuration guidance](https://developer.android.com/build/gradle-tips).
|
|
103
|
+
|
|
104
|
+
## First completed reply
|
|
105
|
+
|
|
106
|
+
Put this in your app module, importing the **app's own namespace** `BuildConfig` if the source
|
|
107
|
+
package differs. Replace `projectKey` with the public key obtained by the agent and `userID`
|
|
108
|
+
with the app's stable user ID. Call from the app's existing coroutine scope and render the result.
|
|
109
|
+
This one-shot check closes its project; a real app keeps one project open for the user session.
|
|
110
|
+
|
|
111
|
+
```kotlin
|
|
112
|
+
import com.google.gson.JsonParser
|
|
113
|
+
import dev.croche.Croche
|
|
114
|
+
import dev.croche.InputStatus
|
|
115
|
+
import dev.croche.MessageStatus
|
|
116
|
+
import dev.croche.OpenOptions
|
|
117
|
+
import dev.croche.SendInput
|
|
118
|
+
import java.util.UUID
|
|
119
|
+
import kotlinx.coroutines.NonCancellable
|
|
120
|
+
import kotlinx.coroutines.withContext
|
|
121
|
+
|
|
122
|
+
suspend fun firstCrocheReply(projectKey: String, userID: String): String {
|
|
123
|
+
val debugKey = if (BuildConfig.DEBUG) {
|
|
124
|
+
BuildConfig.CROCHE_DEBUG_KEY.also {
|
|
125
|
+
check(it.isNotBlank()) { "Debug key is not loaded." }
|
|
126
|
+
}
|
|
127
|
+
} else null
|
|
128
|
+
val config = JsonParser.parseString(
|
|
129
|
+
"""{"model":"deepseek/deepseek-v4.1-flash","instructions":"Help the user with this app."}"""
|
|
130
|
+
).asJsonObject
|
|
131
|
+
val croche = Croche.open(OpenOptions(
|
|
132
|
+
projectKey = projectKey,
|
|
133
|
+
config = config,
|
|
134
|
+
user = userID,
|
|
135
|
+
debugKey = debugKey,
|
|
136
|
+
))
|
|
137
|
+
try {
|
|
138
|
+
val agent = croche.agent()
|
|
139
|
+
val result = agent.request(SendInput(id = UUID.randomUUID().toString(), text = "Hello!"))
|
|
140
|
+
val text = result.messages.filter { it.status == MessageStatus.COMPLETED }
|
|
141
|
+
.joinToString("\n") { it.text }
|
|
142
|
+
check(result.status == InputStatus.ANSWERED && text.isNotEmpty()) {
|
|
143
|
+
"No completed reply; inspect the result status."
|
|
144
|
+
}
|
|
145
|
+
return text
|
|
146
|
+
} finally {
|
|
147
|
+
withContext(NonCancellable) { croche.close() }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The SDK supplies app-private storage on Android; do not pass a Node storage adapter or a JVM
|
|
153
|
+
project directory. A `send` receipt alone is not a completed reply. For new messages use new
|
|
154
|
+
IDs; preserve the ID and payload when retrying the same input. Respect the app's usage
|
|
155
|
+
authorization before a paid turn.
|
|
156
|
+
|
|
157
|
+
## Options and configuration
|
|
158
|
+
|
|
159
|
+
| Option | App-visible meaning |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| `projectKey` | Public project key returned by CLI project creation |
|
|
162
|
+
| `config` | Complete app code config; set `model` explicitly when you want a particular model |
|
|
163
|
+
| `user` | Stable app user ID; do not mix different users in one open project |
|
|
164
|
+
| `debugKey` | SDK debug credential loaded only for Debug; `null` in Release |
|
|
165
|
+
| `language` | User's BCP-47 language; defaults to the device locale when omitted in 0.5.1 |
|
|
166
|
+
|
|
167
|
+
`language` selects `config.languages.<tag>` by exact tag, then primary subtag. If none matches,
|
|
168
|
+
the base config is used as is, written in `config.defaultLanguage` (default `en`): that is the
|
|
169
|
+
config's authored language, **not** the user's. An English-only config can serve a Korean user.
|
|
170
|
+
The model is not told `language`; it replies in the language the user writes unless instructions
|
|
171
|
+
say otherwise. See [config and language](https://docs.croche.ai/concepts/config.md).
|
|
172
|
+
|
|
173
|
+
A Studio config replaces the whole code config at the **next open after sync**, never mid-session.
|
|
174
|
+
Debug-key installs follow drafts. Include **every tool** the app uses and register its handlers.
|
|
175
|
+
Choose a model using [Models](https://docs.croche.ai/models.md).
|
|
176
|
+
|
|
177
|
+
## Verify before shipping
|
|
178
|
+
|
|
179
|
+
- Resolve exactly 0.5.2, build Debug and run on the selected emulator. Confirm a nonempty,
|
|
180
|
+
completed reply; report the real error if it fails. In Studio, inspect **Monitoring → Logs**
|
|
181
|
+
with the development filter. Never paste credentials or private app data into the report.
|
|
182
|
+
- Inspect a clean Release APK/AAB without printing secrets: no debug key in classes/resources,
|
|
183
|
+
no `local.properties`/`.env` bundled, no CLI credential. Git-ignore alone is not enough.
|
|
184
|
+
- Production uses the app's verification setup under **Settings → App verification**, not a
|
|
185
|
+
shipped debug key. An emulator run does not prove real-device production verification.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# iOS · Swift project API
|
|
2
|
+
|
|
3
|
+
Use this guide for a native iOS app, not the single-agent API. It targets **0.5.2** and
|
|
4
|
+
`Croche.open` → `agent()` → `request()`.
|
|
5
|
+
|
|
6
|
+
> Version 0.5.2 is published through SPM. Verify Xcode integration, simulator first turn and
|
|
7
|
+
> release credential exclusion in the target app; package publication is not proof of those checks.
|
|
8
|
+
> If the exact package cannot be resolved, report that blocker; do not downgrade the API.
|
|
9
|
+
|
|
10
|
+
## Install with Swift Package Manager
|
|
11
|
+
|
|
12
|
+
Requires iOS 15+ and a Swift 6-capable Xcode. In Xcode, **File → Add Package Dependencies…**:
|
|
13
|
+
|
|
14
|
+
- URL: `https://github.com/H1R-AI/croche-swift`
|
|
15
|
+
- Dependency rule: **Exact Version**, **0.5.2**
|
|
16
|
+
- Add the **CrocheRuntime** product to your app target; import `CrocheRuntime`.
|
|
17
|
+
|
|
18
|
+
For a Swift package target, add the dependency and product to its existing manifest:
|
|
19
|
+
|
|
20
|
+
```swift
|
|
21
|
+
.package(url: "https://github.com/H1R-AI/croche-swift", exact: "0.5.2")
|
|
22
|
+
// In the app target's dependencies:
|
|
23
|
+
.product(name: "CrocheRuntime", package: "croche-swift")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The distribution supplies the native binary; an app developer does not need a Rust toolchain.
|
|
27
|
+
Do not replace the app's existing package dependencies.
|
|
28
|
+
|
|
29
|
+
## One human step; the agent sets up the project
|
|
30
|
+
|
|
31
|
+
The coding agent installs the CLI with permission. The human signs up at
|
|
32
|
+
[Studio](https://studio.croche.ai), creates one account key under **Account → Account keys**, and
|
|
33
|
+
runs **`croche login`** privately. Never ask for a key in chat or run login for them. Reuse a
|
|
34
|
+
confirmed login. After the human says done, re-check authentication and the private key file,
|
|
35
|
+
then continue setup and the first authorized live turn in the same turn. Capture CLI JSON
|
|
36
|
+
privately; emit only success/IDs/file paths, never raw output, prefixes or any part of a key.
|
|
37
|
+
For key checks, presence/length only. The agent creates/reuses the project and obtains its **public** project key:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
croche auth whoami --json
|
|
41
|
+
croche projects create --name "My app" --json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Do not request a public project key or SDK debug key from the user. The account key
|
|
45
|
+
is only for CLI authentication; it never goes in the app.
|
|
46
|
+
|
|
47
|
+
## Keep the debug key in a private, Debug-only configuration
|
|
48
|
+
|
|
49
|
+
The CLI can write its `CROCHE_DEBUG_KEY` assignment directly to an `.xcconfig` file; Xcode does
|
|
50
|
+
not load the CLI's default `.env`. The agent creates the `Config` directory first, verifies the
|
|
51
|
+
file is not tracked by Git, and runs:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
croche debug-keys create --project PROJECT_ID --env-file Config/Croche.Debug.xcconfig --json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Use the project ID returned above. The CLI prints metadata only and adds the destination to
|
|
58
|
+
`.gitignore`; verify the ignore rule and owner-only file permissions without reading or printing
|
|
59
|
+
the key. Never use secret-print output or force-overwrite an existing key without consent.
|
|
60
|
+
|
|
61
|
+
Wire this up in the app's existing Xcode project:
|
|
62
|
+
|
|
63
|
+
1. Use `Config/Croche.Debug.xcconfig` only as the **Debug** base configuration, or include it
|
|
64
|
+
from the existing Debug-only `.xcconfig`. Preserve existing settings. Do not include it in
|
|
65
|
+
Release or any distribution configuration.
|
|
66
|
+
2. Set Debug's **Info.plist File** (`INFOPLIST_FILE`) to a Debug-specific plist preserving the
|
|
67
|
+
app's required entries. Add the following entry inside its `<dict>`. Keep build-setting
|
|
68
|
+
expansion enabled. Release keeps a separate plist **without this entry**.
|
|
69
|
+
|
|
70
|
+
```xml
|
|
71
|
+
<key>CROCHE_DEBUG_KEY</key>
|
|
72
|
+
<string>$(CROCHE_DEBUG_KEY)</string>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. Keep the private `.xcconfig` outside target resource membership / Copy Bundle Resources.
|
|
76
|
+
Do not copy that file, `.env`, or the CLI credential file into any app bundle. The expanded
|
|
77
|
+
key is permitted only in a local Debug app, never in a Release app/archive.
|
|
78
|
+
4. Ensure `DEBUG` is defined only for Debug. Read the plist value only inside `#if DEBUG`.
|
|
79
|
+
Do not rely on a runtime flag to remove a secret already included in a release artifact.
|
|
80
|
+
|
|
81
|
+
See Apple's [build configuration files](https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project)
|
|
82
|
+
and [build settings](https://developer.apple.com/documentation/xcode/build-settings-reference).
|
|
83
|
+
Do not log expanded build settings or a Debug plist: those can expose the key.
|
|
84
|
+
|
|
85
|
+
## First completed reply
|
|
86
|
+
|
|
87
|
+
Replace `projectKey` with the public key obtained by the agent and `userID` with the app's
|
|
88
|
+
stable user ID. Call this async function from your app; display its returned reply in the UI.
|
|
89
|
+
This one-shot check closes its project; a real app keeps one project open for the user session.
|
|
90
|
+
|
|
91
|
+
```swift
|
|
92
|
+
import Foundation
|
|
93
|
+
import CrocheRuntime
|
|
94
|
+
|
|
95
|
+
func firstCrocheReply(projectKey: String, userID: String) async throws -> String {
|
|
96
|
+
let debugKey: String?
|
|
97
|
+
#if DEBUG
|
|
98
|
+
guard let value = Bundle.main.object(forInfoDictionaryKey: "CROCHE_DEBUG_KEY") as? String,
|
|
99
|
+
!value.isEmpty, !value.contains("$(") else {
|
|
100
|
+
throw NSError(domain: "CrocheSetup", code: 1,
|
|
101
|
+
userInfo: [NSLocalizedDescriptionKey: "Debug key is not loaded."])
|
|
102
|
+
}
|
|
103
|
+
debugKey = value
|
|
104
|
+
#else
|
|
105
|
+
debugKey = nil
|
|
106
|
+
#endif
|
|
107
|
+
|
|
108
|
+
let config = try JSON(#"{"model":"deepseek/deepseek-v4.1-flash","instructions":"Help the user with this app."}"#)
|
|
109
|
+
let croche = try await Croche.open(OpenOptions(
|
|
110
|
+
projectKey: projectKey,
|
|
111
|
+
config: config,
|
|
112
|
+
user: userID,
|
|
113
|
+
debugKey: debugKey
|
|
114
|
+
))
|
|
115
|
+
do {
|
|
116
|
+
let agent = try await croche.agent()
|
|
117
|
+
let result = try await agent.request(SendInput(id: UUID().uuidString, text: "Hello!"))
|
|
118
|
+
let text = result.messages.filter { $0.status == .completed }
|
|
119
|
+
.map(\.text).joined(separator: "\n")
|
|
120
|
+
guard result.status == .answered, !text.isEmpty else {
|
|
121
|
+
throw NSError(domain: "CrocheFirstTurn", code: 2,
|
|
122
|
+
userInfo: [NSLocalizedDescriptionKey: "No completed reply; inspect the result status."])
|
|
123
|
+
}
|
|
124
|
+
try await croche.close()
|
|
125
|
+
return text
|
|
126
|
+
} catch {
|
|
127
|
+
try? await croche.close()
|
|
128
|
+
throw error
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The SDK supplies app-private storage on iOS; do not pass a Node storage adapter. A `send`
|
|
134
|
+
receipt alone is not a completed reply. For new messages use new IDs; preserve the ID and
|
|
135
|
+
payload when retrying the same input. Respect the app's usage authorization before a paid turn.
|
|
136
|
+
|
|
137
|
+
## Options and configuration
|
|
138
|
+
|
|
139
|
+
| Option | App-visible meaning |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| `projectKey` | Public project key returned by CLI project creation |
|
|
142
|
+
| `config` | Complete app code config; set `model` explicitly when you want a particular model |
|
|
143
|
+
| `user` | Stable app user ID; do not mix different users in one open project |
|
|
144
|
+
| `debugKey` | SDK debug credential loaded only for Debug; `nil` in Release |
|
|
145
|
+
| `language` | User's BCP-47 language; defaults to the device locale when omitted in 0.5.1 |
|
|
146
|
+
|
|
147
|
+
`language` selects `config.languages.<tag>` by exact tag, then primary subtag. If none matches,
|
|
148
|
+
the base config is used as is, written in `config.defaultLanguage` (default `en`): that is the
|
|
149
|
+
config's authored language, **not** the user's. An English-only config can serve a Korean user.
|
|
150
|
+
The model is not told `language`; it replies in the language the user writes unless instructions
|
|
151
|
+
say otherwise. See [config and language](https://docs.croche.ai/concepts/config.md).
|
|
152
|
+
|
|
153
|
+
A Studio config replaces the whole code config at the **next open after sync**, never mid-session.
|
|
154
|
+
Debug-key installs follow drafts. Include **every tool** the app uses and register its handlers.
|
|
155
|
+
Choose a model using [Models](https://docs.croche.ai/models.md).
|
|
156
|
+
|
|
157
|
+
## Verify before shipping
|
|
158
|
+
|
|
159
|
+
- Resolve exactly 0.5.2, build Debug and run on the selected simulator. Confirm a nonempty,
|
|
160
|
+
completed reply; report the real error if it fails. In Studio, inspect **Monitoring → Logs**
|
|
161
|
+
with the development filter. Never paste credentials or private app data into the report.
|
|
162
|
+
- Inspect a clean Release archive without printing secrets: no debug key in the binary/plist,
|
|
163
|
+
no private `.xcconfig`/`.env` bundled, no CLI credential. Git-ignore alone is not enough.
|
|
164
|
+
- Production uses the app's verification setup under **Settings → App verification**, not a
|
|
165
|
+
shipped debug key. A simulator run does not prove real-device production verification.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# React Native
|
|
2
|
+
|
|
3
|
+
Requirements: React Native 0.76+ with New Architecture, iOS 15.1+ / Android API 26+.
|
|
4
|
+
Version 0.5.2 packages are published on npm; use the app's existing package manager.
|
|
5
|
+
With permission:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @h1r-ai/croche @h1r-ai/croche-react-native
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
On the iOS build host, run `pod install` from the app's `ios` directory. No manual native SDK
|
|
12
|
+
build is required. Import `Croche` from the RN package. The SDK supplies storage: do not pass
|
|
13
|
+
Node `FileStorage`, `storage`, `secretStorage`, or a server key to the RN integration.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Croche } from '@h1r-ai/croche-react-native';
|
|
17
|
+
|
|
18
|
+
// developmentKey is provided by this app's debug-only build config, not automatic process.env.
|
|
19
|
+
if (__DEV__ && !developmentKey) throw new Error('Load the private debug-only app configuration.');
|
|
20
|
+
const croche = await Croche.open({
|
|
21
|
+
projectKey: publicProjectKey,
|
|
22
|
+
debugKey: __DEV__ ? developmentKey : undefined,
|
|
23
|
+
user: appUserId,
|
|
24
|
+
language: userLocale,
|
|
25
|
+
config: { model: 'deepseek/deepseek-v4.1-flash', instructions: 'You are a helpful guide. Be concise.' },
|
|
26
|
+
});
|
|
27
|
+
const agent = await croche.agent();
|
|
28
|
+
const result = await agent.request({ id: messageId, text: 'Hello!' });
|
|
29
|
+
// Check result.status and final message.status before displaying success.
|
|
30
|
+
// At app-session teardown: await croche.close();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The variables above are app inputs, not new SDK helpers. You obtain the public project key
|
|
34
|
+
from project creation and the SDK debug key through the CLI file-writing workflow;
|
|
35
|
+
the user only runs the signup/developer-key/login step. Neither the CLI-created `.env` nor
|
|
36
|
+
`process.env.CROCHE_DEBUG_KEY` automatically populates a React Native app. Inspect the existing
|
|
37
|
+
build configuration and map `CROCHE_DEBUG_KEY` from the ignored file into its **debug-only**
|
|
38
|
+
`developmentKey` input before opening Croche. Do not invent a package import or add a loader
|
|
39
|
+
dependency without permission. If no loader exists, report that specific build-wiring blocker;
|
|
40
|
+
do not ask for the secret or pretend Node's env-file flag injects a mobile bundle.
|
|
41
|
+
|
|
42
|
+
The guard above refuses a missing debug-build key without displaying it. Rebuild the debug app
|
|
43
|
+
after changing its build configuration and verify a real turn. Exclude the value **at build time**
|
|
44
|
+
from every release artifact and inspect the release configuration/bundle for accidental inclusion.
|
|
45
|
+
`__DEV__` gating alone is not evidence that a bundled secret was removed. Never commit a literal
|
|
46
|
+
secret or embed the CLI `dk_` credential. CLI file behavior remains pending verification.
|
|
47
|
+
|
|
48
|
+
Pass the app user's BCP-47 locale explicitly until RN automatic device locale is verified in
|
|
49
|
+
0.5.1. Use the core skill's messages/tools references for the shared project/agent surface.
|
|
50
|
+
Test a simulator or emulator first; real-device release verification is a separate step.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Web: keep app secrets on the backend
|
|
2
|
+
|
|
3
|
+
Never put a debug key or server key in the browser, **including local development**. Run
|
|
4
|
+
`Croche.open` in your Node backend and let the page call your authenticated app endpoint.
|
|
5
|
+
Do not expose secrets through frontend `VITE_`, `NEXT_PUBLIC_` or similar public build variables.
|
|
6
|
+
|
|
7
|
+
## Local development: use the CLI-created private file on the server
|
|
8
|
+
|
|
9
|
+
The agent creates the debug-key `.env` through the core skill's CLI flow. Load it into the
|
|
10
|
+
**server process** with `node --env-file=.env server/app.mjs`, substituting the actual server
|
|
11
|
+
entry point/file path, or use the project's existing server-side dotenv setup before opening
|
|
12
|
+
Croche. Plain Node does not load it automatically. The flag exists from Node 20.6; Croche
|
|
13
|
+
requires Node 22+. Use its value as `debugKey` on that local backend, never in browser code.
|
|
14
|
+
Refuse a missing server-process value locally without printing it. The user does not need to
|
|
15
|
+
create a second credential for this first-turn check; `croche login` does not populate SDK values.
|
|
16
|
+
|
|
17
|
+
## Production: server credential setup
|
|
18
|
+
|
|
19
|
+
Ask the user to open project **Settings → Keys → Server keys**, create/copy the `csk_` server
|
|
20
|
+
key privately, and set `CROCHE_SERVER_KEY` in their server's secret environment. No chat paste.
|
|
21
|
+
For a private local server terminal:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
export CROCHE_SERVER_KEY="<server key>"
|
|
25
|
+
```
|
|
26
|
+
```powershell
|
|
27
|
+
$env:CROCHE_SERVER_KEY="<server key>"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
PowerShell is syntax guidance only; Windows verification is pending. Do not use frontend
|
|
31
|
+
`VITE_`, `NEXT_PUBLIC_` or similar public build variables for secrets.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { Croche } from '@h1r-ai/croche';
|
|
35
|
+
import { FileStorage } from '@h1r-ai/croche/node';
|
|
36
|
+
|
|
37
|
+
// userId comes from a verified app session; userStoragePath is an app-owned isolated path.
|
|
38
|
+
const croche = await Croche.open({
|
|
39
|
+
projectKey: process.env.CROCHE_PROJECT_KEY!,
|
|
40
|
+
serverKey: process.env.CROCHE_SERVER_KEY!,
|
|
41
|
+
user: userId,
|
|
42
|
+
language: userLocale,
|
|
43
|
+
storage: new FileStorage(userStoragePath),
|
|
44
|
+
config: { model: 'deepseek/deepseek-v4.1-flash', instructions: 'Help this person use our app.' },
|
|
45
|
+
});
|
|
46
|
+
const agent = await croche.agent();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Reuse one open project per authenticated user; do not open overlapping writers to the same
|
|
50
|
+
store or share one conversation across visitors. Do not accept a browser-supplied user ID as
|
|
51
|
+
authentication or interpolate it unchecked into a storage path. Apply your app's access controls
|
|
52
|
+
and anonymous-user limits before a paid request. Stream public message events through your own
|
|
53
|
+
endpoint, not the project's credentials. Close the project on session/service shutdown.
|
|
54
|
+
|
|
55
|
+
Croche runs the model for you; production usage is charged to your project's credit.
|
|
56
|
+
Guide the user to **Settings → Budget & limits** if app access or spending is blocked; never
|
|
57
|
+
increase limits on their behalf just to pass a test. Studio config applies at next open after
|
|
58
|
+
sync; a backend using a server key receives released versions, not development drafts.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: croche-troubleshoot
|
|
3
|
+
description: Diagnose a failed Croche SDK turn, CLI command, Studio config update, or persisted store using its error code and guide the user to the next safe action. Use for missing credentials, exhausted credit or allowance, invite activation, unavailable model access, draft conflicts, or memory-store recovery.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Diagnose, then guide the user
|
|
7
|
+
|
|
8
|
+
Collect only the SDK/CLI version, platform/shell, failed step, error **code**, final status and
|
|
9
|
+
approximate time. Ask for redacted output, not keys, invite codes, environment dumps, full user
|
|
10
|
+
conversations, or Studio secret screenshots. For SDK requests, inspect both thrown errors and
|
|
11
|
+
final `message.end` errors; a receipt is not a completed turn.
|
|
12
|
+
|
|
13
|
+
Do read-only/local checks first. Do not loop paid requests, repeatedly replay a tool mutation,
|
|
14
|
+
raise a budget, switch identity, revoke keys, or delete a store as an automatic repair.
|
|
15
|
+
Tell the user where to act, then retry once only after the cause changes and retry is authorized.
|
|
16
|
+
|
|
17
|
+
| Error / symptom | What to check or do | What to tell the user |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `invite_required` | Account activation is incomplete. | “Sign in to Studio and redeem your invite privately. Do not send me the code.” |
|
|
20
|
+
| CLI account command: `missing_credentials` | Capture `auth whoami` privately and report authentication status only, never prefixes, stored files or environment values; `cdt_` is not an account key. | “Sign up, create an account key at Account → Account keys (under Personal), then run `croche login` yourself and enter it at the hidden prompt.” Login remains pending verification; the agent never runs it. Local-control credentials are separate; do not substitute the account key for them. |
|
|
21
|
+
| `account_credit_exhausted` | Production Runtime credit is unavailable. Stop further paid checks. | “Check your account → Billing → Runtime credits. Decide yourself whether to add credit; I will not purchase or raise limits.” |
|
|
22
|
+
| `development_allowance_exhausted` | The Studio development allowance is exhausted. | “Check account → Billing → Studio plan for the allowance shown. A total cap does not necessarily reset next week; don't create more keys to bypass it.” |
|
|
23
|
+
| `project_budget_exhausted` | Read project budget and app access status. | “Check project → Settings → Budget & limits. Only change the budget if that is your intended spending decision.” |
|
|
24
|
+
| `unverified_allowance_exhausted` | The allowance for installs without platform proof is exhausted. | “Check Settings → App verification and Budget & limits. Another install/key is not a reset; completing the proper app-verification path is a separate release task.” |
|
|
25
|
+
| `gateway_unavailable` | Model access is unavailable. Check Studio project status; wait for sync before one authorized retry. | “Croche could not run the model right now. If it persists, send support the redacted error code, project ID and time.” Do not ask for another kind of model-service credential. |
|
|
26
|
+
| `human_session_required` | This action requires the signed-in human. | “Please complete this in Studio.” Do not try a different credential or endpoint to bypass approval. |
|
|
27
|
+
| `draft_conflict` | Preserve the local edit; fetch the latest draft into another file, compare and reconcile. | “Someone changed the draft. I will show the difference before saving the combined edit.” |
|
|
28
|
+
| `unsupported_encoding` | The CLI input file is UTF-16 instead of UTF-8. | “Save it as UTF-8; in Windows PowerShell 5.1 use `Set-Content ... -Encoding UTF8`.” Windows execution remains unverified. |
|
|
29
|
+
| `invalid_configuration` | Validate option names/types, declarations and handlers; remove invented options, not requested capabilities. | Explain the specific invalid field using the installed SDK's API. For replacement/locale rules use `croche-config`. |
|
|
30
|
+
| `memory_store_too_old` | Opening this agent was refused without changing its data. | Read [recovery.md](references/recovery.md); obtain informed consent before a destructive reset. |
|
|
31
|
+
| `store_busy` | Another owner still has the store open. | Close the correct app/project before reopening; do not delete lock/storage files or an unrelated process. |
|
|
32
|
+
| `idempotency_conflict` | A prior input ID was reused with different content. | Restore the original ID/payload for delivery retry; use a new ID only for an explicitly new request, after checking prior effects. |
|
|
33
|
+
|
|
34
|
+
## Debug-key setup failures
|
|
35
|
+
|
|
36
|
+
Candidate CLI errors below still need verification against the installed release. Never use
|
|
37
|
+
secret output as a fallback.
|
|
38
|
+
|
|
39
|
+
- `tracked_env_file`: choose an untracked, ignored destination; do not write into source control.
|
|
40
|
+
- `debug_key_exists`: no key was issued; preserve the existing value. `--force` needs explicit
|
|
41
|
+
consent, not an automatic retry.
|
|
42
|
+
- `invalid_env_file`: use an existing destination directory and a regular non-symlink file;
|
|
43
|
+
duplicate SDK key assignments are refused. Do not display the file to diagnose it.
|
|
44
|
+
- `env_write_failed`: a key may already have been issued; use the reported `key_id` to identify
|
|
45
|
+
it, explain the failure and revoke only that key when authorized, with
|
|
46
|
+
`croche debug-keys revoke --project PROJECT_ID KEY_ID --json`. Do not blindly create another.
|
|
47
|
+
|
|
48
|
+
If the command is missing, report the release blocker rather than asking the user to create
|
|
49
|
+
and paste a debug key. If an existing different `.env` value is refused, preserve it and ask
|
|
50
|
+
before `--force`; do not display either value. If the file is not ignored or protected, fix
|
|
51
|
+
only the file metadata/ignore rule without reading secrets into the transcript. After a timeout,
|
|
52
|
+
inspect key metadata before retrying creation. Node should load the private file directly with
|
|
53
|
+
`node --env-file=.env app.mjs` (or existing dotenv); plain Node does not load `.env`.
|
|
54
|
+
For web, fix the server's loader, never a browser variable. For RN, fix the debug-only build
|
|
55
|
+
config, rebuild the debug app and ensure release artifacts exclude the key. Successful CLI
|
|
56
|
+
login does not supply SDK values. A missing SDK variable is not a reason to request its value.
|
|
57
|
+
|
|
58
|
+
## No error, but the result looks wrong
|
|
59
|
+
|
|
60
|
+
- **Draft not visible:** `Croche.open`, development `debugKey`, sync then next open, full config
|
|
61
|
+
and all registered tools. A server-key production install does not receive drafts.
|
|
62
|
+
- **Wrong language:** `language` is the user's locale and selects config, not reply language.
|
|
63
|
+
A missing translation uses the base unchanged. Read `croche-config` before changing defaults.
|
|
64
|
+
- **No Studio activity:** development turns appear in **Monitoring → Logs**, not Activity;
|
|
65
|
+
allow reporting time and choose the development usage filter.
|
|
66
|
+
- **Tool says it will check but never answers:** confirm the read-only command has `reads: true`.
|
|
67
|
+
Validate handler output; do not mock the action and report success.
|
|
68
|
+
- **Timed-out mutation:** an effect may already exist. Inspect the result/app state before any
|
|
69
|
+
resend. Keep the original input ID and payload for delivery retry; a new ID can duplicate work.
|
|
70
|
+
|
|
71
|
+
Report what was observed, what changed, what was actually rerun, and what the user still needs
|
|
72
|
+
to do. A syntax check, package install, or Studio sign-in alone is not a successful SDK turn.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# An older store was refused
|
|
2
|
+
|
|
3
|
+
Use only for `memory_store_too_old`. `Croche.open` can succeed while `croche.agent(id)` refuses
|
|
4
|
+
that agent's store; other agents can still open. The refused open does not change the data.
|
|
5
|
+
|
|
6
|
+
Tell the user plainly: **This agent's saved data cannot be opened by this SDK. Nothing was
|
|
7
|
+
changed. Resetting this agent permanently deletes its conversation, memories and saved
|
|
8
|
+
documents for this user. Only an older build that still runs can export them first.**
|
|
9
|
+
Do not suggest that the current build can migrate or export a store it cannot open.
|
|
10
|
+
|
|
11
|
+
1. Identify the exact app user, agent ID and storage. Offer export with a still-working older
|
|
12
|
+
build when available; never claim an export happened without checking it.
|
|
13
|
+
2. Get explicit consent for that scoped, permanent loss. Without consent, leave the store
|
|
14
|
+
intact and report the version/error. Do not automatically reset inside an error handler.
|
|
15
|
+
3. For the **project API**, close the project first, then use the same original open options:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
await croche.close();
|
|
19
|
+
await Croche.deleteStore({ ...openOptions, agent: agentId });
|
|
20
|
+
const reopened = await Croche.open(openOptions);
|
|
21
|
+
const agent = await reopened.agent(agentId);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `'default'` for the default agent. This removes that agent's conversation, memories,
|
|
25
|
+
documents and message history for this user, not other agents. Drop app retry entries already
|
|
26
|
+
accepted by the deleted store; their old final status cannot arrive. Verify the intended empty
|
|
27
|
+
agent without deleting the whole project directory or another user's data.
|
|
28
|
+
|
|
29
|
+
Do not apply this recipe blindly to custom single-agent storage or an instance-specific case;
|
|
30
|
+
confirm the installed SDK's scoped deletion API first. A busy store must be closed, not forcibly
|
|
31
|
+
erased. Native 0.5.2 recovery requires its reviewed API; do not translate this snippet by guesswork.
|