@usenaive-sdk/runtime 0.1.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/dist/index.cjs ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ agentProfile: () => agentProfile
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_server = require("@usenaive-sdk/server");
27
+ function env(name) {
28
+ return typeof process !== "undefined" ? process.env?.[name] : void 0;
29
+ }
30
+ function client() {
31
+ const apiKey = env("NAIVE_AGENT_PROFILE_TOKEN") ?? env("NAIVE_SECRET_KEY") ?? env("NAIVE_API_KEY");
32
+ if (!apiKey) {
33
+ throw new Error(
34
+ "@usenaive-sdk/runtime: no agent profile credential found. Expected NAIVE_AGENT_PROFILE_TOKEN (injected by the Na\xEFve runtime) or NAIVE_SECRET_KEY in the environment."
35
+ );
36
+ }
37
+ return new import_server.Naive({ apiKey, baseUrl: env("NAIVE_API_URL") });
38
+ }
39
+ var agentProfile = {
40
+ get id() {
41
+ return env("NAIVE_AGENT_PROFILE_ID");
42
+ },
43
+ tools() {
44
+ const userScope = env("NAIVE_AGENT_PROFILE_USER") ?? "default";
45
+ return client().forUser(userScope).tools();
46
+ }
47
+ };
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ agentProfile
51
+ });
52
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @usenaive-sdk/runtime — for code running *inside* a Naïve-hosted agent (microVM).\n *\n * The agent boots with its agent profile credentials injected as environment\n * variables (never baked into the image, never on the agent's filesystem). This\n * module reads them and hands back the current agent profile's governed toolset, so\n * the agent loop can call tools without ever holding a raw card/identity secret\n * — every call still routes through the governance gateway.\n *\n * import { agent profile } from \"@usenaive-sdk/runtime\";\n * const tools = agentProfile.tools();\n * await runAgentLoop({ tools, goal: \"Resolve tickets.\" });\n *\n * For BYO runtimes (Eve / AgentCore / LangGraph / your own harness), use\n * `@usenaive-sdk/server` and pull `op.tools()` there instead.\n */\nimport { Naive, type NaiveAgentToolset } from \"@usenaive-sdk/server\";\n\nexport interface AgentProfileRuntimeContext {\n /** The agent profile id this agent is running as (from NAIVE_AGENT_PROFILE_ID). */\n readonly id: string | undefined;\n /** The governed toolset scoped to the current agentProfile. */\n tools(): NaiveAgentToolset;\n}\n\nfunction env(name: string): string | undefined {\n return typeof process !== \"undefined\" ? process.env?.[name] : undefined;\n}\n\nfunction client(): Naive {\n const apiKey = env(\"NAIVE_AGENT_PROFILE_TOKEN\") ?? env(\"NAIVE_SECRET_KEY\") ?? env(\"NAIVE_API_KEY\");\n if (!apiKey) {\n throw new Error(\n \"@usenaive-sdk/runtime: no agent profile credential found. Expected NAIVE_AGENT_PROFILE_TOKEN \" +\n \"(injected by the Naïve runtime) or NAIVE_SECRET_KEY in the environment.\",\n );\n }\n return new Naive({ apiKey, baseUrl: env(\"NAIVE_API_URL\") });\n}\n\n/** The current agent profile context, resolved from the injected runtime environment. */\nexport const agentProfile: AgentProfileRuntimeContext = {\n get id() {\n return env(\"NAIVE_AGENT_PROFILE_ID\");\n },\n tools(): NaiveAgentToolset {\n const userScope = env(\"NAIVE_AGENT_PROFILE_USER\") ?? \"default\";\n return client().forUser(userScope).tools();\n },\n};\n\nexport type { NaiveAgentToolset } from \"@usenaive-sdk/server\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAA8C;AAS9C,SAAS,IAAI,MAAkC;AAC7C,SAAO,OAAO,YAAY,cAAc,QAAQ,MAAM,IAAI,IAAI;AAChE;AAEA,SAAS,SAAgB;AACvB,QAAM,SAAS,IAAI,2BAA2B,KAAK,IAAI,kBAAkB,KAAK,IAAI,eAAe;AACjG,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO,IAAI,oBAAM,EAAE,QAAQ,SAAS,IAAI,eAAe,EAAE,CAAC;AAC5D;AAGO,IAAM,eAA2C;AAAA,EACtD,IAAI,KAAK;AACP,WAAO,IAAI,wBAAwB;AAAA,EACrC;AAAA,EACA,QAA2B;AACzB,UAAM,YAAY,IAAI,0BAA0B,KAAK;AACrD,WAAO,OAAO,EAAE,QAAQ,SAAS,EAAE,MAAM;AAAA,EAC3C;AACF;","names":[]}
@@ -0,0 +1,30 @@
1
+ import { NaiveAgentToolset } from '@usenaive-sdk/server';
2
+ export { NaiveAgentToolset } from '@usenaive-sdk/server';
3
+
4
+ /**
5
+ * @usenaive-sdk/runtime — for code running *inside* a Naïve-hosted agent (microVM).
6
+ *
7
+ * The agent boots with its agent profile credentials injected as environment
8
+ * variables (never baked into the image, never on the agent's filesystem). This
9
+ * module reads them and hands back the current agent profile's governed toolset, so
10
+ * the agent loop can call tools without ever holding a raw card/identity secret
11
+ * — every call still routes through the governance gateway.
12
+ *
13
+ * import { agent profile } from "@usenaive-sdk/runtime";
14
+ * const tools = agentProfile.tools();
15
+ * await runAgentLoop({ tools, goal: "Resolve tickets." });
16
+ *
17
+ * For BYO runtimes (Eve / AgentCore / LangGraph / your own harness), use
18
+ * `@usenaive-sdk/server` and pull `op.tools()` there instead.
19
+ */
20
+
21
+ interface AgentProfileRuntimeContext {
22
+ /** The agent profile id this agent is running as (from NAIVE_AGENT_PROFILE_ID). */
23
+ readonly id: string | undefined;
24
+ /** The governed toolset scoped to the current agentProfile. */
25
+ tools(): NaiveAgentToolset;
26
+ }
27
+ /** The current agent profile context, resolved from the injected runtime environment. */
28
+ declare const agentProfile: AgentProfileRuntimeContext;
29
+
30
+ export { type AgentProfileRuntimeContext, agentProfile };
@@ -0,0 +1,30 @@
1
+ import { NaiveAgentToolset } from '@usenaive-sdk/server';
2
+ export { NaiveAgentToolset } from '@usenaive-sdk/server';
3
+
4
+ /**
5
+ * @usenaive-sdk/runtime — for code running *inside* a Naïve-hosted agent (microVM).
6
+ *
7
+ * The agent boots with its agent profile credentials injected as environment
8
+ * variables (never baked into the image, never on the agent's filesystem). This
9
+ * module reads them and hands back the current agent profile's governed toolset, so
10
+ * the agent loop can call tools without ever holding a raw card/identity secret
11
+ * — every call still routes through the governance gateway.
12
+ *
13
+ * import { agent profile } from "@usenaive-sdk/runtime";
14
+ * const tools = agentProfile.tools();
15
+ * await runAgentLoop({ tools, goal: "Resolve tickets." });
16
+ *
17
+ * For BYO runtimes (Eve / AgentCore / LangGraph / your own harness), use
18
+ * `@usenaive-sdk/server` and pull `op.tools()` there instead.
19
+ */
20
+
21
+ interface AgentProfileRuntimeContext {
22
+ /** The agent profile id this agent is running as (from NAIVE_AGENT_PROFILE_ID). */
23
+ readonly id: string | undefined;
24
+ /** The governed toolset scoped to the current agentProfile. */
25
+ tools(): NaiveAgentToolset;
26
+ }
27
+ /** The current agent profile context, resolved from the injected runtime environment. */
28
+ declare const agentProfile: AgentProfileRuntimeContext;
29
+
30
+ export { type AgentProfileRuntimeContext, agentProfile };
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ // src/index.ts
2
+ import { Naive } from "@usenaive-sdk/server";
3
+ function env(name) {
4
+ return typeof process !== "undefined" ? process.env?.[name] : void 0;
5
+ }
6
+ function client() {
7
+ const apiKey = env("NAIVE_AGENT_PROFILE_TOKEN") ?? env("NAIVE_SECRET_KEY") ?? env("NAIVE_API_KEY");
8
+ if (!apiKey) {
9
+ throw new Error(
10
+ "@usenaive-sdk/runtime: no agent profile credential found. Expected NAIVE_AGENT_PROFILE_TOKEN (injected by the Na\xEFve runtime) or NAIVE_SECRET_KEY in the environment."
11
+ );
12
+ }
13
+ return new Naive({ apiKey, baseUrl: env("NAIVE_API_URL") });
14
+ }
15
+ var agentProfile = {
16
+ get id() {
17
+ return env("NAIVE_AGENT_PROFILE_ID");
18
+ },
19
+ tools() {
20
+ const userScope = env("NAIVE_AGENT_PROFILE_USER") ?? "default";
21
+ return client().forUser(userScope).tools();
22
+ }
23
+ };
24
+ export {
25
+ agentProfile
26
+ };
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @usenaive-sdk/runtime — for code running *inside* a Naïve-hosted agent (microVM).\n *\n * The agent boots with its agent profile credentials injected as environment\n * variables (never baked into the image, never on the agent's filesystem). This\n * module reads them and hands back the current agent profile's governed toolset, so\n * the agent loop can call tools without ever holding a raw card/identity secret\n * — every call still routes through the governance gateway.\n *\n * import { agent profile } from \"@usenaive-sdk/runtime\";\n * const tools = agentProfile.tools();\n * await runAgentLoop({ tools, goal: \"Resolve tickets.\" });\n *\n * For BYO runtimes (Eve / AgentCore / LangGraph / your own harness), use\n * `@usenaive-sdk/server` and pull `op.tools()` there instead.\n */\nimport { Naive, type NaiveAgentToolset } from \"@usenaive-sdk/server\";\n\nexport interface AgentProfileRuntimeContext {\n /** The agent profile id this agent is running as (from NAIVE_AGENT_PROFILE_ID). */\n readonly id: string | undefined;\n /** The governed toolset scoped to the current agentProfile. */\n tools(): NaiveAgentToolset;\n}\n\nfunction env(name: string): string | undefined {\n return typeof process !== \"undefined\" ? process.env?.[name] : undefined;\n}\n\nfunction client(): Naive {\n const apiKey = env(\"NAIVE_AGENT_PROFILE_TOKEN\") ?? env(\"NAIVE_SECRET_KEY\") ?? env(\"NAIVE_API_KEY\");\n if (!apiKey) {\n throw new Error(\n \"@usenaive-sdk/runtime: no agent profile credential found. Expected NAIVE_AGENT_PROFILE_TOKEN \" +\n \"(injected by the Naïve runtime) or NAIVE_SECRET_KEY in the environment.\",\n );\n }\n return new Naive({ apiKey, baseUrl: env(\"NAIVE_API_URL\") });\n}\n\n/** The current agent profile context, resolved from the injected runtime environment. */\nexport const agentProfile: AgentProfileRuntimeContext = {\n get id() {\n return env(\"NAIVE_AGENT_PROFILE_ID\");\n },\n tools(): NaiveAgentToolset {\n const userScope = env(\"NAIVE_AGENT_PROFILE_USER\") ?? \"default\";\n return client().forUser(userScope).tools();\n },\n};\n\nexport type { NaiveAgentToolset } from \"@usenaive-sdk/server\";\n"],"mappings":";AAgBA,SAAS,aAAqC;AAS9C,SAAS,IAAI,MAAkC;AAC7C,SAAO,OAAO,YAAY,cAAc,QAAQ,MAAM,IAAI,IAAI;AAChE;AAEA,SAAS,SAAgB;AACvB,QAAM,SAAS,IAAI,2BAA2B,KAAK,IAAI,kBAAkB,KAAK,IAAI,eAAe;AACjG,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO,IAAI,MAAM,EAAE,QAAQ,SAAS,IAAI,eAAe,EAAE,CAAC;AAC5D;AAGO,IAAM,eAA2C;AAAA,EACtD,IAAI,KAAK;AACP,WAAO,IAAI,wBAAwB;AAAA,EACrC;AAAA,EACA,QAA2B;AACzB,UAAM,YAAY,IAAI,0BAA0B,KAAK;AACrD,WAAO,OAAO,EAAE,QAAQ,SAAS,EAAE,MAAM;AAAA,EAC3C;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@usenaive-sdk/runtime",
3
+ "version": "0.1.0",
4
+ "description": "Naïve runtime SDK — used inside a hosted agent to access the current agent profile's governed toolset.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "dependencies": {
24
+ "@usenaive-sdk/server": "0.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^22.15.3",
28
+ "tsup": "^8.0.0",
29
+ "typescript": "^5.7.3"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "typecheck": "tsc --noEmit"
34
+ }
35
+ }