Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
run: |
set -euo pipefail
version=$(node -p 'JSON.parse(require("fs").readFileSync("package.json")).version')
package_spec="@clone-ai/tab-completion@$version"
package_spec="@clone-ai/prompt-prediction@$version"
unset NPM_TOKEN NODE_AUTH_TOKEN
export NPM_CONFIG_USERCONFIG="$RUNNER_TEMP/anonymous-user.npmrc"
export NPM_CONFIG_GLOBALCONFIG="$RUNNER_TEMP/anonymous-global.npmrc"
Expand All @@ -121,10 +121,10 @@ jobs:
consumer="$RUNNER_TEMP/npm-consumer"
npm install --prefix "$consumer" --ignore-scripts --prefer-online "$package_spec"
cd "$consumer"
node --input-type=module -e 'await import("@clone-ai/tab-completion"); await import("@clone-ai/tab-completion/server")'
node --input-type=module -e 'await import("@clone-ai/prompt-prediction"); await import("@clone-ai/prompt-prediction/server")'
npm audit signatures
registry_tarball=$(npm pack "$package_spec" --pack-destination "$RUNNER_TEMP" --json | node -e 'let s=""; process.stdin.on("data",c=>s+=c).on("end",()=>console.log(JSON.parse(s)[0].filename))')
cmp "$RUNNER_TEMP/$registry_tarball" "$GITHUB_WORKSPACE/release/clone-ai-tab-completion-$version.tgz"
cmp "$RUNNER_TEMP/$registry_tarball" "$GITHUB_WORKSPACE/release/clone-ai-prompt-prediction-$version.tgz"
pypi:
if: inputs.registry == 'pypi'
needs: [release_check, validate]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
(cd "$download_dir" && sha256sum --check ./*.sha256)
npm install --prefix "$consumer_dir" --ignore-scripts "$download_dir"/*.tgz
cd "$consumer_dir"
node --input-type=module -e 'await import("@clone-ai/tab-completion"); await import("@clone-ai/tab-completion/server")'
node --input-type=module -e 'await import("@clone-ai/prompt-prediction"); await import("@clone-ai/prompt-prediction/server")'
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.7.0

- Publish the JavaScript SDK as `@clone-ai/prompt-prediction`. Update imports, generated integration examples, archive names, npm verification and installation guides. Runtime exports and prediction behavior remain unchanged.

# 0.6.4

- Include public npm installation instructions in the distributed README and integration guides. Keep exact package versions and checksum-verified archive alternatives aligned, and point billing guidance to the API pricing page.
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Add next-prompt prediction and Tab completion to your existing composer. Suggestions appear as ghost text. **Tab inserts; your application decides when to send.**

**SDK 0.6.4:** instant display remains the default. Set `presentation="typewriter"` for a cancellable display animation after the complete JSON response arrives; the API does not stream. These options and Clone mode are absent from the 0.3.1 package. Keep ordinary typing and sending available when predictions are loading, fail, or never return. See the [rendering contract](docs/agent-integration.md#suggestion-rendering-contract) before building a custom editor adapter.
**SDK 0.7.0:** instant display remains the default. Set `presentation="typewriter"` for a cancellable display animation after the complete JSON response arrives; the API does not stream. These options and Clone mode are absent from the 0.3.1 package. Keep ordinary typing and sending available when predictions are loading, fail, or never return. See the [rendering contract](docs/agent-integration.md#suggestion-rendering-contract) before building a custom editor adapter.

Use your product's conversation, selected artifact and user preferences as context. Your end users do not need a Clone account. Connecting a user's Clone context is optional.

Expand Down Expand Up @@ -34,16 +34,16 @@ Node **22.13+**, ESM. React integrations support **18 and 19**. The headless con
Install the public npm package. Existing integrations can keep their pinned version while validating an upgrade:

```sh
npm install --save-exact @clone-ai/tab-completion@0.6.4
npm install --save-exact @clone-ai/prompt-prediction@0.7.0
```

Use your project's package manager and commit its lockfile. Verified [GitHub release archives](docs/releases.md#download-and-install) remain available. Hosted API access requires a separate app key.

```tsx
'use client';
import { useState } from 'react';
import { createPredictionTransport } from '@clone-ai/tab-completion';
import { TabCompletionInput } from '@clone-ai/tab-completion/react';
import { createPredictionTransport } from '@clone-ai/prompt-prediction';
import { TabCompletionInput } from '@clone-ai/prompt-prediction/react';

const transport = createPredictionTransport('/api/clone/predict');

Expand All @@ -70,7 +70,7 @@ export function Composer({ threadId, contextRevision }: {
}
```

Implement `/api/clone/predict` in your authenticated backend using `CloneClient` from `@clone-ai/tab-completion/server`. Derive the user ID from the server session. Keep the app key on the server, never in browser code or `VITE_*` / `NEXT_PUBLIC_*` variables. Pass your real conversation and advance `context_revision` when it changes.
Implement `/api/clone/predict` in your authenticated backend using `CloneClient` from `@clone-ai/prompt-prediction/server`. Derive the user ID from the server session. Keep the app key on the server, never in browser code or `VITE_*` / `NEXT_PUBLIC_*` variables. Pass your real conversation and advance `context_revision` when it changes.

For complete setup and verification, follow the [integration guide](docs/start.md).

Expand All @@ -94,10 +94,10 @@ For a connected proxy, outage testing and private measurements, follow [pilot va

| Import | Use it for |
| --- | --- |
| `@clone-ai/tab-completion` | Controller, browser transport, errors and public types |
| `@clone-ai/tab-completion/react` | `useTabCompletion` or `TabCompletionInput` |
| `@clone-ai/tab-completion/assistant-ui` | `CloneComposerInput` inside an existing assistant-ui composer |
| `@clone-ai/tab-completion/server` | `CloneClient` and optional PKCE connection flow |
| `@clone-ai/prompt-prediction` | Controller, browser transport, errors and public types |
| `@clone-ai/prompt-prediction/react` | `useTabCompletion` or `TabCompletionInput` |
| `@clone-ai/prompt-prediction/assistant-ui` | `CloneComposerInput` inside an existing assistant-ui composer |
| `@clone-ai/prompt-prediction/server` | `CloneClient` and optional PKCE connection flow |

The React input uses a native textarea. Rich-text editors need an insertion and Undo adapter around the controller. The assistant-ui adapter targets `@assistant-ui/react@0.15.21` and uses its `unstable_useComposerInput` hook; verify compatibility before upgrading it.

Expand All @@ -118,4 +118,4 @@ See [Contributing](CONTRIBUTING.md) for the repository layout and validation com

## Feedback loop

SDK 0.6.4 can return explicit rejection, evaluations, edited successful submissions and host-observed outcomes to the API. Wire the packaged tracker to your host send and authenticated proxy. Text collection is off by default. See [feedback integration](docs/feedback.md) for scoped memory, delivery, expiry and clearing. These features require the API feedback deployment; event collection alone is not model learning.
SDK 0.7.0 can return explicit rejection, evaluations, edited successful submissions and host-observed outcomes to the API. Wire the packaged tracker to your host send and authenticated proxy. Text collection is off by default. See [feedback integration](docs/feedback.md) for scoped memory, delivery, expiry and clearing. These features require the API feedback deployment; event collection alone is not model learning.
10 changes: 5 additions & 5 deletions docs/agent-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Implement next-prompt prediction and Tab Completion in the existing customer composer using product context by default, preserving its submission behavior. No Clone end-user account, consent screen or callback is required for this basic path. Offer Clone personalization separately in settings only if desired. Read `README.md`, exported types and `openapi.json`. Do not infer that the customer uses assistant-ui just because the optional adapter exists.

Begin with [start.md](start.md), which covers agent-led self-service app registration and callback updates. This guide supplies the detailed implementation contract for SDK 0.6.4. Verify installed types; 0.3.1 has no typewriter option or Clone mode.
Begin with [start.md](start.md), which covers agent-led self-service app registration and callback updates. This guide supplies the detailed implementation contract for SDK 0.7.0. Verify installed types; 0.3.1 has no typewriter option or Clone mode.

## Prerequisites

- The public `@clone-ai/tab-completion@0.6.4` npm package, Node 22.13+, React 18 or 19. Follow the [installation instructions](releases.md#download-and-install). Checksum-verified GitHub archives are also available.
- The public `@clone-ai/prompt-prediction@0.7.0` npm package, Node 22.13+, React 18 or 19. Follow the [installation instructions](releases.md#download-and-install). Checksum-verified GitHub archives are also available.
- A Clone app key (`clnp_...`) for the chosen production or sandbox app and its API base URL. Use an isolated sandbox app for synthetic integration tests. Only optional personalization needs an exact registered HTTPS callback (HTTP loopback is local/test only). The agent obtains these through self-service onboarding; the customer need not prepare them in advance.
- An existing authenticated customer session and server-side session storage.
- Only for optional personalization: a Clone test account with selected profile/Goal context already synced. Basic verification needs no Clone test account. Local-only unsynced content is unavailable.
Expand All @@ -16,7 +16,7 @@ The app key is required for API verification; a callback and Clone account are r

## Server integration

Import `CloneClient` and `ConnectionFlow` from `@clone-ai/tab-completion/server`. Create the client once in a server-only module:
Import `CloneClient` and `ConnectionFlow` from `@clone-ai/prompt-prediction/server`. Create the client once in a server-only module:

```ts
const clone = new CloneClient({ apiKey: process.env.CLONE_APP_KEY!, baseUrl: process.env.CLONE_API_URL! });
Expand Down Expand Up @@ -72,13 +72,13 @@ Use the bubbling `onInput` observer shown in the example. Updating observation s

The example distinguishes the SDK insertion from a later edit, removes attribution after clearing or Undo back to the original draft, and associates a submission with the most recently accepted suggestion. It does not measure how much suggested text remains or every suggestion used in a draft. `presented` means the controller offered a candidate; it does not prove the user read it. Adapt these observation boundaries explicitly if your editor behaves differently. No draft or completion text is included in the transmitted `{event_id, request_id, kind}`.

Telemetry is best effort and must not block input or send. The example shows local `pending`/`recorded`/`failed` delivery receipts; fixture receipts are labelled separately. SDK 0.6.4 uses bounded retries with the same event ID/body; it does not persist a durable retry queue. Reset the tracker on account/context changes to abort old-scope delivery. Report failed/missing deliveries instead of treating them as zero engagement. Verify acceptance without send, edited submission, Undo followed by an unrelated manual send, context change, telemetry failure, duplicate delivery, and unchanged billable usage. These event records alone do not establish coverage, usefulness, suggestion quality or human acceptance.
Telemetry is best effort and must not block input or send. The example shows local `pending`/`recorded`/`failed` delivery receipts; fixture receipts are labelled separately. SDK 0.7.0 uses bounded retries with the same event ID/body; it does not persist a durable retry queue. Reset the tracker on account/context changes to abort old-scope delivery. Report failed/missing deliveries instead of treating them as zero engagement. Verify acceptance without send, edited submission, Undo followed by an unrelated manual send, context change, telemetry failure, duplicate delivery, and unchanged billable usage. These event records alone do not establish coverage, usefulness, suggestion quality or human acceptance.

## Suggestion rendering contract

The prediction endpoint returns one complete JSON object, not SSE or token deltas. `createPredictionTransport` waits for that response, the controller validates it, and the controller validates the complete candidate. By default `useTabCompletion` exposes the full `completion` immediately and `TabCompletionInput` renders it as ghost text. With `presentation: "typewriter"`, the hook exposes a visible prefix until the animation completes; `canAccept` remains false until then. The complete candidate remains in `state.candidate`. This is the default for both empty-composer next prompts and draft completions.

Do not add per-character timers, progressively slice `completion`, or route it through an assistant-message streaming renderer by default. A typewriter animation is an optional presentation choice, not evidence that the API streams. In 0.6.4 set `presentation: "typewriter"` only when the customer's stated preference or an AskUserQuestion answer calls for it; do not ask again for a choice already supplied. The entire candidate must be visible before offering Tab acceptance; never accept only a partial string or send unseen text. Cancel any animation on edits, selection/context changes, dismissal, or expiry. Ordinary manual sending must stay available throughout.
Do not add per-character timers, progressively slice `completion`, or route it through an assistant-message streaming renderer by default. A typewriter animation is an optional presentation choice, not evidence that the API streams. In 0.7.0 set `presentation: "typewriter"` only when the customer's stated preference or an AskUserQuestion answer calls for it; do not ask again for a choice already supplied. The entire candidate must be visible before offering Tab acceptance; never accept only a partial string or send unseen text. Cancel any animation on edits, selection/context changes, dismissal, or expiry. Ordinary manual sending must stay available throughout.

Verify the installed package version and lockfile, inspect the actual composer adapter, and check the response format before attributing progressive display to the SDK or customer code. A recording alone cannot establish which layer produced an effect. Return evidence that the default renderer shows a complete candidate, Tab inserts it exactly once without sending, and only the host's explicit-send action submits it.

Expand Down
2 changes: 1 addition & 1 deletion docs/billing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pricing and billing

SDK 0.6.4 supports both sandbox and pay-as-you-go (PAYG) usage, including an optional company spending limit. Install the verified [0.6.4 release](https://github.com/cloneisyou/clone-sdk/releases/tag/v0.6.4). Hosted paid activation is available only when the developer console offers it; installing the SDK never enables payment.
SDK 0.7.0 supports both sandbox and pay-as-you-go (PAYG) usage, including an optional company spending limit. Install the verified [0.7.0 release](https://github.com/cloneisyou/clone-sdk/releases/tag/v0.7.0). Hosted paid activation is available only when the developer console offers it; installing the SDK never enables payment.

The company operating your product pays for hosted predictions. End users need no Clone account or personal subscription. SDK code is MIT licensed. The public catalog is [API pricing](https://clone.is/api-platform/pricing); availability depends on rollout, and existing individually negotiated contracts remain unchanged.

Expand Down
2 changes: 1 addition & 1 deletion docs/clone-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Default bounds are three sends and five minutes. The host can choose one to 100
## Headless integration

```ts
import { CloneModeController } from '@clone-ai/tab-completion';
import { CloneModeController } from '@clone-ai/prompt-prediction';
const mode = new CloneModeController({
transport,
onSubmit: async (text, { requestId, origin, signal }) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SDK 0.6.2 adds `FeedbackTracker`, bounded event delivery, explicit rejection/eva
## Host integration

```ts
import { FeedbackTracker, createEventTransport } from '@clone-ai/tab-completion';
import { FeedbackTracker, createEventTransport } from '@clone-ai/prompt-prediction';

const feedback = new FeedbackTracker(createEventTransport('/api/clone/events'), {
collectSubmittedText: false, // default: no submitted text collection
Expand Down
Loading
Loading