@agentick/apple 0.7.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.
- package/README.md +290 -0
- package/dist/.tsbuildinfo.build +1 -0
- package/dist/apple-model.d.ts +23 -0
- package/dist/apple-model.d.ts.map +1 -0
- package/dist/apple-model.jsx +23 -0
- package/dist/apple-model.jsx.map +1 -0
- package/dist/apple.d.ts +43 -0
- package/dist/apple.d.ts.map +1 -0
- package/dist/apple.js +296 -0
- package/dist/apple.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/inference.swift +444 -0
- package/package.json +50 -0
- package/src/index.ts +36 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ModelComponentProps } from "@agentick/core/jsx";
|
|
2
|
+
import { type AppleAdapterConfig } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Props for AppleModel component.
|
|
5
|
+
*/
|
|
6
|
+
export interface AppleModelProps extends AppleAdapterConfig {
|
|
7
|
+
/** Optional callback when model is mounted */
|
|
8
|
+
onMount?: ModelComponentProps["onMount"];
|
|
9
|
+
/** Optional callback when model is unmounted */
|
|
10
|
+
onUnmount?: ModelComponentProps["onUnmount"];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* AppleModel component for declarative model configuration in JSX.
|
|
14
|
+
*
|
|
15
|
+
* Creates an Apple Foundation Models adapter internally and wraps it in a Model component.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <AppleModel bridgePath="./apple-fm-bridge" />
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function AppleModel(props: AppleModelProps): import("@agentick/core/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=apple-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-model.d.ts","sourceRoot":"","sources":["../src/apple-model.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,mBAAmB,EAAS,MAAM,oBAAoB,CAAC;AAGrE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD,8CAA8C;IAC9C,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACzC,gDAAgD;IAChD,SAAS,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,oDAIhD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// JSX Component
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import { Model } from "@agentick/core/jsx";
|
|
5
|
+
import { createElement } from "@agentick/core/jsx-runtime";
|
|
6
|
+
import { createAppleModel } from "./apple";
|
|
7
|
+
import {} from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* AppleModel component for declarative model configuration in JSX.
|
|
10
|
+
*
|
|
11
|
+
* Creates an Apple Foundation Models adapter internally and wraps it in a Model component.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <AppleModel bridgePath="./apple-fm-bridge" />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function AppleModel(props) {
|
|
19
|
+
const { onMount, onUnmount, ...adapterConfig } = props;
|
|
20
|
+
const adapter = createAppleModel(adapterConfig);
|
|
21
|
+
return createElement(Model, { model: adapter, onMount, onUnmount });
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=apple-model.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-model.jsx","sourceRoot":"","sources":["../src/apple-model.tsx"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,OAAO,EAA4B,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAA2B,MAAM,SAAS,CAAC;AAYlD;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,aAAa,EAAE,GAAG,KAAK,CAAC;IACvD,MAAM,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/apple.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apple Foundation Models Adapter
|
|
3
|
+
*
|
|
4
|
+
* Wraps Apple's on-device Foundation Models (~3B parameter) via a compiled
|
|
5
|
+
* Swift bridge executable. Communicates over stdin/stdout JSON:
|
|
6
|
+
*
|
|
7
|
+
* Node.js ──stdin JSON──▶ Swift bridge ──stdout JSON/NDJSON──▶ Node.js
|
|
8
|
+
*
|
|
9
|
+
* Non-streaming: single JSON ModelOutput on stdout
|
|
10
|
+
* Streaming: NDJSON lines, each an AdapterDelta-compatible object
|
|
11
|
+
*
|
|
12
|
+
* Requires macOS 26+ with Apple Intelligence enabled.
|
|
13
|
+
*/
|
|
14
|
+
import { type ModelClass } from "@agentick/core/model";
|
|
15
|
+
import type { AppleAdapterConfig } from "./types";
|
|
16
|
+
/**
|
|
17
|
+
* Create an Apple Foundation Models adapter.
|
|
18
|
+
*
|
|
19
|
+
* Uses a compiled Swift bridge to communicate with the on-device model.
|
|
20
|
+
* The bridge must be compiled from the provided inference.swift:
|
|
21
|
+
*
|
|
22
|
+
* ```bash
|
|
23
|
+
* swiftc -parse-as-library -framework FoundationModels inference.swift -o apple-fm-bridge
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function createAppleModel(config?: AppleAdapterConfig): ModelClass;
|
|
27
|
+
/**
|
|
28
|
+
* Convenience factory for creating an Apple Foundation Models adapter.
|
|
29
|
+
*
|
|
30
|
+
* The bridge binary is auto-compiled on install. No config needed for defaults.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { apple } from '@agentick/apple';
|
|
35
|
+
*
|
|
36
|
+
* const model = apple();
|
|
37
|
+
*
|
|
38
|
+
* // Or with explicit bridge path
|
|
39
|
+
* const model = apple({ bridgePath: '/path/to/apple-fm-bridge' });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function apple(config?: AppleAdapterConfig): ModelClass;
|
|
43
|
+
//# sourceMappingURL=apple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple.d.ts","sourceRoot":"","sources":["../src/apple.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EACV,kBAAkB,EAQnB,MAAM,SAAS,CAAC;AAUjB;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,kBAAuB,GAAG,UAAU,CAmH5E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,MAAM,GAAE,kBAAuB,GAAG,UAAU,CAEjE"}
|
package/dist/apple.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apple Foundation Models Adapter
|
|
3
|
+
*
|
|
4
|
+
* Wraps Apple's on-device Foundation Models (~3B parameter) via a compiled
|
|
5
|
+
* Swift bridge executable. Communicates over stdin/stdout JSON:
|
|
6
|
+
*
|
|
7
|
+
* Node.js ──stdin JSON──▶ Swift bridge ──stdout JSON/NDJSON──▶ Node.js
|
|
8
|
+
*
|
|
9
|
+
* Non-streaming: single JSON ModelOutput on stdout
|
|
10
|
+
* Streaming: NDJSON lines, each an AdapterDelta-compatible object
|
|
11
|
+
*
|
|
12
|
+
* Requires macOS 26+ with Apple Intelligence enabled.
|
|
13
|
+
*/
|
|
14
|
+
import { spawn } from "node:child_process";
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import { join, dirname } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { createAdapter, StopReason, } from "@agentick/core/model";
|
|
19
|
+
import { normalizeModelInput } from "@agentick/core/utils";
|
|
20
|
+
import { STOP_REASON_MAP } from "./types";
|
|
21
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const DEFAULT_BRIDGE_PATH = join(__dirname, "..", "bin", "apple-fm-bridge");
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Factory Function
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Create an Apple Foundation Models adapter.
|
|
28
|
+
*
|
|
29
|
+
* Uses a compiled Swift bridge to communicate with the on-device model.
|
|
30
|
+
* The bridge must be compiled from the provided inference.swift:
|
|
31
|
+
*
|
|
32
|
+
* ```bash
|
|
33
|
+
* swiftc -parse-as-library -framework FoundationModels inference.swift -o apple-fm-bridge
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function createAppleModel(config = {}) {
|
|
37
|
+
const modelId = config.model ?? "apple-foundation-3b";
|
|
38
|
+
const bridgePath = resolveBridgePath(config.bridgePath);
|
|
39
|
+
return createAdapter({
|
|
40
|
+
metadata: {
|
|
41
|
+
id: modelId,
|
|
42
|
+
provider: "apple",
|
|
43
|
+
model: modelId,
|
|
44
|
+
type: "language",
|
|
45
|
+
capabilities: [
|
|
46
|
+
{ stream: true, toolCalls: false },
|
|
47
|
+
{
|
|
48
|
+
messageTransformation: () => ({
|
|
49
|
+
preferredRenderer: "markdown",
|
|
50
|
+
roleMapping: {
|
|
51
|
+
event: "user",
|
|
52
|
+
ephemeral: "user",
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
contextWindow: 4096,
|
|
58
|
+
supportsVision: false,
|
|
59
|
+
supportsToolUse: false,
|
|
60
|
+
supportsStructuredOutput: true,
|
|
61
|
+
},
|
|
62
|
+
prepareInput: (input) => {
|
|
63
|
+
const normalized = normalizeModelInput(input, { model: modelId });
|
|
64
|
+
// Extract system prompt from system-role messages or system field
|
|
65
|
+
const systemMessages = normalized.messages.filter((m) => m.role === "system");
|
|
66
|
+
const system = input.system ||
|
|
67
|
+
systemMessages
|
|
68
|
+
.map((m) => m.content
|
|
69
|
+
.filter((b) => b.type === "text")
|
|
70
|
+
.map((b) => b.text)
|
|
71
|
+
.join("\n"))
|
|
72
|
+
.join("\n") ||
|
|
73
|
+
undefined;
|
|
74
|
+
// Convert non-system messages to bridge wire format
|
|
75
|
+
const messages = normalized.messages
|
|
76
|
+
.filter((m) => m.role !== "system")
|
|
77
|
+
.map((m) => ({
|
|
78
|
+
role: m.role,
|
|
79
|
+
content: m.content.map((b) => {
|
|
80
|
+
if (b.type === "text")
|
|
81
|
+
return { type: "text", text: b.text };
|
|
82
|
+
return { type: b.type, text: JSON.stringify(b) };
|
|
83
|
+
}),
|
|
84
|
+
}));
|
|
85
|
+
// Map ResponseFormat to BridgeResponseFormat
|
|
86
|
+
const responseFormat = input.responseFormat
|
|
87
|
+
? convertResponseFormat(input.responseFormat)
|
|
88
|
+
: undefined;
|
|
89
|
+
return {
|
|
90
|
+
messages,
|
|
91
|
+
system,
|
|
92
|
+
temperature: input.temperature,
|
|
93
|
+
maxTokens: input.maxTokens,
|
|
94
|
+
stream: false,
|
|
95
|
+
responseFormat,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
mapChunk: (chunk) => {
|
|
99
|
+
switch (chunk.type) {
|
|
100
|
+
case "text":
|
|
101
|
+
return { type: "text", delta: chunk.delta };
|
|
102
|
+
case "message_end":
|
|
103
|
+
return {
|
|
104
|
+
type: "message_end",
|
|
105
|
+
stopReason: STOP_REASON_MAP[chunk.stopReason] ?? StopReason.STOP,
|
|
106
|
+
usage: chunk.usage,
|
|
107
|
+
};
|
|
108
|
+
case "error":
|
|
109
|
+
return { type: "error", error: chunk.error };
|
|
110
|
+
default:
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
processOutput: async (output) => {
|
|
115
|
+
const content = output.message.content.map((b) => ({
|
|
116
|
+
type: "text",
|
|
117
|
+
text: b.text,
|
|
118
|
+
}));
|
|
119
|
+
const message = { role: "assistant", content };
|
|
120
|
+
return {
|
|
121
|
+
model: output.model,
|
|
122
|
+
createdAt: output.createdAt,
|
|
123
|
+
messages: [message],
|
|
124
|
+
message,
|
|
125
|
+
stopReason: STOP_REASON_MAP[output.stopReason] ?? StopReason.STOP,
|
|
126
|
+
usage: output.usage,
|
|
127
|
+
raw: output,
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
execute: async (input) => {
|
|
131
|
+
return runBridge(bridgePath, { ...input, stream: false });
|
|
132
|
+
},
|
|
133
|
+
executeStream: async function* (input) {
|
|
134
|
+
yield* streamBridge(bridgePath, { ...input, stream: true });
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Convenience factory for creating an Apple Foundation Models adapter.
|
|
140
|
+
*
|
|
141
|
+
* The bridge binary is auto-compiled on install. No config needed for defaults.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* import { apple } from '@agentick/apple';
|
|
146
|
+
*
|
|
147
|
+
* const model = apple();
|
|
148
|
+
*
|
|
149
|
+
* // Or with explicit bridge path
|
|
150
|
+
* const model = apple({ bridgePath: '/path/to/apple-fm-bridge' });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export function apple(config = {}) {
|
|
154
|
+
return createAppleModel(config);
|
|
155
|
+
}
|
|
156
|
+
// ============================================================================
|
|
157
|
+
// Response Format Conversion
|
|
158
|
+
// ============================================================================
|
|
159
|
+
function convertResponseFormat(format) {
|
|
160
|
+
if (format.type === "text") {
|
|
161
|
+
return { type: "text" };
|
|
162
|
+
}
|
|
163
|
+
if (format.type === "json") {
|
|
164
|
+
return { type: "json" };
|
|
165
|
+
}
|
|
166
|
+
if (format.type === "json_schema") {
|
|
167
|
+
// Convert JSON Schema to BridgeJsonSchema
|
|
168
|
+
const schema = format.schema;
|
|
169
|
+
return {
|
|
170
|
+
type: "json_schema",
|
|
171
|
+
schema: convertJsonSchema(schema),
|
|
172
|
+
name: format.name,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
function convertJsonSchema(schema) {
|
|
178
|
+
if (schema.type !== "object") {
|
|
179
|
+
throw new Error("Apple Foundation Models only supports object root schemas");
|
|
180
|
+
}
|
|
181
|
+
const properties = {};
|
|
182
|
+
for (const [key, value] of Object.entries(schema.properties || {})) {
|
|
183
|
+
properties[key] = convertSchemaProperty(value);
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties,
|
|
188
|
+
description: schema.description,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function convertSchemaProperty(prop) {
|
|
192
|
+
const base = {
|
|
193
|
+
type: prop.type === "integer" ? "integer" : prop.type,
|
|
194
|
+
description: prop.description,
|
|
195
|
+
};
|
|
196
|
+
if (prop.type === "object" && prop.properties) {
|
|
197
|
+
base.properties = {};
|
|
198
|
+
for (const [key, value] of Object.entries(prop.properties)) {
|
|
199
|
+
base.properties[key] = convertSchemaProperty(value);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (prop.type === "array" && prop.items) {
|
|
203
|
+
base.items = convertSchemaProperty(prop.items);
|
|
204
|
+
}
|
|
205
|
+
return base;
|
|
206
|
+
}
|
|
207
|
+
// ============================================================================
|
|
208
|
+
// Bridge Path Resolution
|
|
209
|
+
// ============================================================================
|
|
210
|
+
function resolveBridgePath(explicit) {
|
|
211
|
+
if (explicit)
|
|
212
|
+
return explicit;
|
|
213
|
+
// Default: compiled binary next to this package
|
|
214
|
+
if (existsSync(DEFAULT_BRIDGE_PATH))
|
|
215
|
+
return DEFAULT_BRIDGE_PATH;
|
|
216
|
+
// Fallback: check if it's in PATH (e.g. node_modules/.bin symlink)
|
|
217
|
+
return "apple-fm-bridge";
|
|
218
|
+
}
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// Process Bridge
|
|
221
|
+
// ============================================================================
|
|
222
|
+
/** Spawn the Swift bridge, write JSON to stdin, collect full stdout as BridgeOutput */
|
|
223
|
+
function runBridge(bridgePath, input) {
|
|
224
|
+
return new Promise((resolve, reject) => {
|
|
225
|
+
const proc = spawn(bridgePath, [], { stdio: ["pipe", "pipe", "pipe"] });
|
|
226
|
+
let stdout = "";
|
|
227
|
+
let stderr = "";
|
|
228
|
+
proc.stdout.on("data", (data) => {
|
|
229
|
+
stdout += data.toString();
|
|
230
|
+
});
|
|
231
|
+
proc.stderr.on("data", (data) => {
|
|
232
|
+
stderr += data.toString();
|
|
233
|
+
});
|
|
234
|
+
proc.on("error", (err) => {
|
|
235
|
+
reject(new Error(`Failed to spawn Apple FM bridge at ${bridgePath}: ${err.message}`));
|
|
236
|
+
});
|
|
237
|
+
proc.on("close", (code) => {
|
|
238
|
+
if (code !== 0) {
|
|
239
|
+
reject(new Error(`Apple FM bridge exited with code ${code}: ${stderr}`));
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
const output = JSON.parse(stdout.trim());
|
|
244
|
+
if (output.type === "error") {
|
|
245
|
+
reject(new Error(`Apple Foundation Models: ${output.error}`));
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
resolve(output);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
reject(new Error(`Failed to parse bridge output: ${stdout.slice(0, 200)}`));
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
proc.stdin.write(JSON.stringify(input));
|
|
255
|
+
proc.stdin.end();
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/** Spawn the Swift bridge, write JSON to stdin, yield NDJSON chunks from stdout */
|
|
259
|
+
async function* streamBridge(bridgePath, input) {
|
|
260
|
+
const proc = spawn(bridgePath, [], { stdio: ["pipe", "pipe", "pipe"] });
|
|
261
|
+
let stderrBuf = "";
|
|
262
|
+
proc.stderr.on("data", (data) => {
|
|
263
|
+
stderrBuf += data.toString();
|
|
264
|
+
});
|
|
265
|
+
proc.stdin.write(JSON.stringify(input));
|
|
266
|
+
proc.stdin.end();
|
|
267
|
+
let buffer = "";
|
|
268
|
+
for await (const data of proc.stdout) {
|
|
269
|
+
buffer += data.toString();
|
|
270
|
+
const lines = buffer.split("\n");
|
|
271
|
+
buffer = lines.pop() || "";
|
|
272
|
+
for (const line of lines) {
|
|
273
|
+
const trimmed = line.trim();
|
|
274
|
+
if (!trimmed)
|
|
275
|
+
continue;
|
|
276
|
+
try {
|
|
277
|
+
yield JSON.parse(trimmed);
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
// skip unparseable lines
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (buffer.trim()) {
|
|
285
|
+
try {
|
|
286
|
+
yield JSON.parse(buffer.trim());
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
// skip
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (stderrBuf.trim()) {
|
|
293
|
+
yield { type: "error", error: stderrBuf.trim() };
|
|
294
|
+
}
|
|
295
|
+
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ACP,OAAO;QACT,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QACrB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;IACnD,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Agentick Apple Foundation Models Adapter
|
|
3
|
+
*
|
|
4
|
+
* On-device inference via Apple's Foundation Models framework (macOS 26+).
|
|
5
|
+
* Uses a compiled Swift bridge executable for communication.
|
|
6
|
+
*
|
|
7
|
+
* ## Features
|
|
8
|
+
*
|
|
9
|
+
* - **On-Device** — ~3B parameter model running locally on Apple Silicon
|
|
10
|
+
* - **Streaming** — Full streaming support via NDJSON
|
|
11
|
+
* - **Vision** — Multimodal input (text + images)
|
|
12
|
+
* - **Private** — All inference on-device, no network required
|
|
13
|
+
* - **Free** — No API keys or usage costs
|
|
14
|
+
*
|
|
15
|
+
* ## Prerequisites
|
|
16
|
+
*
|
|
17
|
+
* 1. macOS 26+ (Tahoe) with Apple Intelligence enabled
|
|
18
|
+
* 2. Compile the Swift bridge:
|
|
19
|
+
* ```bash
|
|
20
|
+
* swiftc -parse-as-library -framework FoundationModels inference.swift -o apple-fm-bridge
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ## Quick Start
|
|
24
|
+
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { apple } from '@agentick/apple';
|
|
27
|
+
*
|
|
28
|
+
* const model = apple({ bridgePath: './apple-fm-bridge' });
|
|
29
|
+
* const app = createApp(Agent, { model });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @module @agentick/apple
|
|
33
|
+
*/
|
|
34
|
+
export * from "./apple-model";
|
|
35
|
+
export * from "./apple";
|
|
36
|
+
export type { AppleAdapterConfig, BridgeInput, BridgeOutput, BridgeChunk } from "./types";
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Agentick Apple Foundation Models Adapter
|
|
3
|
+
*
|
|
4
|
+
* On-device inference via Apple's Foundation Models framework (macOS 26+).
|
|
5
|
+
* Uses a compiled Swift bridge executable for communication.
|
|
6
|
+
*
|
|
7
|
+
* ## Features
|
|
8
|
+
*
|
|
9
|
+
* - **On-Device** — ~3B parameter model running locally on Apple Silicon
|
|
10
|
+
* - **Streaming** — Full streaming support via NDJSON
|
|
11
|
+
* - **Vision** — Multimodal input (text + images)
|
|
12
|
+
* - **Private** — All inference on-device, no network required
|
|
13
|
+
* - **Free** — No API keys or usage costs
|
|
14
|
+
*
|
|
15
|
+
* ## Prerequisites
|
|
16
|
+
*
|
|
17
|
+
* 1. macOS 26+ (Tahoe) with Apple Intelligence enabled
|
|
18
|
+
* 2. Compile the Swift bridge:
|
|
19
|
+
* ```bash
|
|
20
|
+
* swiftc -parse-as-library -framework FoundationModels inference.swift -o apple-fm-bridge
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ## Quick Start
|
|
24
|
+
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { apple } from '@agentick/apple';
|
|
27
|
+
*
|
|
28
|
+
* const model = apple({ bridgePath: './apple-fm-bridge' });
|
|
29
|
+
* const app = createApp(Agent, { model });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @module @agentick/apple
|
|
33
|
+
*/
|
|
34
|
+
export * from "./apple-model";
|
|
35
|
+
export * from "./apple";
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apple Foundation Models adapter configuration and types.
|
|
3
|
+
*/
|
|
4
|
+
import { StopReason } from "@agentick/shared";
|
|
5
|
+
/**
|
|
6
|
+
* Apple Foundation Models adapter configuration.
|
|
7
|
+
*/
|
|
8
|
+
export interface AppleAdapterConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Path to the compiled Swift bridge executable.
|
|
11
|
+
* Defaults to the binary compiled by the package's postinstall script.
|
|
12
|
+
*/
|
|
13
|
+
bridgePath?: string;
|
|
14
|
+
/** Model identifier (default: "apple-foundation-3b") */
|
|
15
|
+
model?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Input sent to the Swift bridge via stdin */
|
|
18
|
+
export interface BridgeInput {
|
|
19
|
+
messages: BridgeMessage[];
|
|
20
|
+
system?: string;
|
|
21
|
+
temperature?: number;
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
stream: boolean;
|
|
24
|
+
responseFormat?: BridgeResponseFormat;
|
|
25
|
+
}
|
|
26
|
+
/** Response format for structured output */
|
|
27
|
+
export type BridgeResponseFormat = {
|
|
28
|
+
type: "text";
|
|
29
|
+
} | {
|
|
30
|
+
type: "json";
|
|
31
|
+
} | {
|
|
32
|
+
type: "json_schema";
|
|
33
|
+
schema: BridgeJsonSchema;
|
|
34
|
+
name?: string;
|
|
35
|
+
};
|
|
36
|
+
/** JSON Schema structure for DynamicGenerationSchema conversion */
|
|
37
|
+
export interface BridgeJsonSchema {
|
|
38
|
+
type: "object";
|
|
39
|
+
properties: Record<string, BridgeSchemaProperty>;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface BridgeSchemaProperty {
|
|
43
|
+
type: "string" | "number" | "integer" | "boolean" | "object" | "array";
|
|
44
|
+
description?: string;
|
|
45
|
+
properties?: Record<string, BridgeSchemaProperty>;
|
|
46
|
+
items?: BridgeSchemaProperty;
|
|
47
|
+
}
|
|
48
|
+
export interface BridgeMessage {
|
|
49
|
+
role: string;
|
|
50
|
+
content: string | Array<{
|
|
51
|
+
type: string;
|
|
52
|
+
text?: string;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
/** Non-streaming response from the bridge (stdout JSON) */
|
|
56
|
+
export interface BridgeOutput {
|
|
57
|
+
model: string;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
message: {
|
|
60
|
+
role: string;
|
|
61
|
+
content: Array<{
|
|
62
|
+
type: string;
|
|
63
|
+
text: string;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
stopReason: string;
|
|
67
|
+
usage: BridgeUsage;
|
|
68
|
+
}
|
|
69
|
+
export interface BridgeUsage {
|
|
70
|
+
inputTokens: number;
|
|
71
|
+
outputTokens: number;
|
|
72
|
+
totalTokens: number;
|
|
73
|
+
}
|
|
74
|
+
/** Streaming chunks from the bridge (stdout NDJSON lines) */
|
|
75
|
+
export type BridgeChunk = {
|
|
76
|
+
type: "text";
|
|
77
|
+
delta: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: "message_end";
|
|
80
|
+
stopReason: string;
|
|
81
|
+
usage: BridgeUsage;
|
|
82
|
+
} | {
|
|
83
|
+
type: "error";
|
|
84
|
+
error: string;
|
|
85
|
+
};
|
|
86
|
+
export declare const STOP_REASON_MAP: Record<string, StopReason>;
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","source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,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1D;AAED,2DAA2D;AAC3D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAMrC,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAGtD,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apple Foundation Models adapter configuration and types.
|
|
3
|
+
*/
|
|
4
|
+
import { StopReason } from "@agentick/shared";
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Stop Reason Mapping
|
|
7
|
+
// ============================================================================
|
|
8
|
+
export const STOP_REASON_MAP = {
|
|
9
|
+
stop: StopReason.STOP,
|
|
10
|
+
max_tokens: StopReason.MAX_TOKENS,
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA+E9C,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,eAAe,GAA+B;IACzD,IAAI,EAAE,UAAU,CAAC,IAAI;IACrB,UAAU,EAAE,UAAU,CAAC,UAAU;CAClC,CAAC"}
|